/** * actionPlannerTypes.ts — S553: tipi puri estratti da actionPlanner.ts * * Contiene solo TypeScript types/interfaces senza dipendenze runtime. * Permette import type-only senza pull-in di actionPlanner.ts * (eventRuntime, checkPolicy, Dexie taskStore, ecc.). * * Consumato da actionPlanner.ts (re-esporta per backward compat) e * da agentLoop.ts / agentSSE.ts che tipano ActionStep / ActionPlan. */ import type { RiskLevel } from "@/lib/capabilityPolicy"; export type StepStatus = "pending" | "running" | "done" | "error" | "skipped" | "waiting_confirm"; export interface ActionStep { id: string; tool: string; args: Record; label: string; risk: RiskLevel; preview: string; status: StepStatus; result?: unknown; error?: string; startedAt?: number; doneAt?: number; } export interface ActionPlan { id: string; goal: string; steps: ActionStep[]; taskId: string; } export interface PlannerCallbacks { /** Chiamato prima di ogni step — permette di aggiornare UI */ onStepStart?: (step: ActionStep) => void; /** Chiamato al completamento di uno step */ onStepDone?: (step: ActionStep, result: unknown) => void; /** Chiamato su errore step non-fatal */ onStepError?: (step: ActionStep, error: string) => void; /** Richiesta conferma per step risky/dangerous — ritorna true=procedi, false=salta */ onNeedConfirm?: (step: ActionStep) => Promise; /** Chiamato al termine del piano */ onPlanDone?: (plan: ActionPlan, success: boolean) => void; } export type ToolExecutor = (tool: string, args: Record) => Promise;