AUDIT / src /lib /actionPlannerTypes.ts
Arypulka98's picture
feat(audit): deploy full backend cluster node (part 2)
cc11e77 verified
Raw
History Blame Contribute Delete
1.69 kB
/**
* 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<string, unknown>;
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<boolean>;
/** Chiamato al termine del piano */
onPlanDone?: (plan: ActionPlan, success: boolean) => void;
}
export type ToolExecutor = (tool: string, args: Record<string, unknown>) => Promise<unknown>;