import type { AgentLifecycleOperation, AgentLifecycleState } from "@paperclipai/shared"; import type { LifecycleCommand } from "../domain/policy.js"; export interface LifecycleAgent { id: string; companyId: string; lifecycleState: AgentLifecycleState; lifecycleVersion: number; lifecycleHolds?: readonly string[]; lifecycleRequiredPluginIds: string[] | null; lifecycleError: string | null; lifecycleOperation: AgentLifecycleOperation | null; } export interface LifecycleStore { get(id: string): Promise; change(id: string, command: LifecycleCommand, options?: { version?: number; owner?: string; reason?: string }): Promise; claim(id: string, owner: string, now: Date): Promise; renew(agent: LifecycleAgent, owner: string, now: Date): Promise; setRequiredPlugins(agent: LifecycleAgent, owner: string, pluginIds: string[]): Promise; completeHost(agent: LifecycleAgent, owner: string): Promise; completePlugin(agent: LifecycleAgent, owner: string, pluginId: string): Promise; defer(agent: LifecycleAgent, owner: string, error: string | null, now: Date, options?: { retryRequired: boolean; verificationFailures?: number }): Promise; pending(limit: number, now: Date): Promise; } export interface LifecycleDriver { requiredPluginIds(agent: LifecycleAgent): Promise; runHost(agent: LifecycleAgent): Promise<"complete" | "pending">; runPlugin(agent: LifecycleAgent, pluginId: string): Promise<"complete" | "pending">; /** Notify the scheduler only after readiness has committed. */ onReady?(agent: LifecycleAgent): Promise; } export interface LifecycleFailure { stage: "claim" | "renew" | "select_plugins" | "save_plugins" | "host" | "plugin" | "complete_host" | "complete_plugin" | "transition" | "defer" | "scan" | "policy_scan" | "ready"; agentId?: string; companyId?: string; phase?: AgentLifecycleState; operationId?: string; version?: number; attempts?: number; verificationFailures?: number; pluginId?: string; }