/** * Persisted and in-memory types for action-layer execution history and health. * * @module */ import type { RiskGateStatus } from "../../health/types.js"; import type { ActionType, DecisionMode } from "../types.js"; /** Gateway between {@link ActionResult.data} and persisted audit records. */ export interface DecisionMeta { durationMs: number; tokensUsed: number | null; mode: DecisionMode; model: string | null; execute: boolean; confidence: number; reasoning: string; } /** One persisted line in `history.jsonl` — full audit trail per `action.handle()` call. */ export interface ActionExecutionRecord { id: string; actionName: string; actionType: ActionType; address: string; startedAt: number; finishedAt: number; durationMs: number; trigger: { eventType: string; scannerId: string | null; signalCount: number; topAssets: string[]; }; decision: { mode: DecisionMode; model: string | null; execute: boolean; confidence: number; reasoning: string; durationMs: number | null; tokensUsed: number | null; } | null; /** Interpolated decision prompt (LLM/rule path); null when not applicable or not supplied. */ decisionPrompt: string | null; /** * The persisted subset of the runtime's gate evaluations. `gateId`/`gateName` stay plain strings: * this record is parsed back out of an untrusted payload, so it must be able to hold an id the * current {@link RiskGateId} enum does not know. The verdicts are the runtime's own enum — those * are the values readers branch on, and a re-spelling would drift. */ riskSnapshot: { gate: Exclude; gates: Array<{ gateId: string; gateName: string; status: RiskGateStatus; reason?: string; metrics?: Record; }>; } | null; outcome: { success: boolean; skipped: boolean; skipReason: string | null; summary: string; error: string | null; submittedCount: number | null; closedCount: number | null; firedCount: number | null; failedCount: number | null; skippedCount: number | null; assets: string[]; }; } /** Snapshot written to `latest.json` for offline inspection. */ export interface ActionLatestState { actionName: string; actionType: ActionType; address: string; decisionMode: DecisionMode; lastExecution: ActionExecutionRecord | null; runCount: number; successCount: number; errorCount: number; skipCount: number; consecutiveErrorCount: number; totalDecisionsExecute: number; totalDecisionsNoExecute: number; totalTokensUsed: number; updatedAt: number; } /** In-memory counters for one `(address, actionName)` pair. */ export interface ActionTelemetry { inFlight: boolean; lastRunStartedAt: number | null; lastRunFinishedAt: number | null; lastRunStatus: "success" | "error" | "skipped" | null; lastSkipReason: string | null; lastError: string | null; lastErrorAt: number | null; runCount: number; successCount: number; errorCount: number; skipCount: number; consecutiveErrorCount: number; lastDecisionExecute: boolean | null; lastDecisionConfidence: number | null; totalDecisionsExecute: number; totalDecisionsNoExecute: number; totalTokensUsed: number; lastExecutedAssets: string[]; } /** * Filters when reading rolling JSONL history. * `with_decision` — rows where the decision engine ran (`decision` is non-null). * `executed` — rows where the decision engine ran AND decided to execute (`decision.execute === true`). */ export type ActionHistoryOutcomeFilter = "all" | "with_decision" | "executed"; export interface ReadActionHistoryOptions { limit?: number; sinceMs?: number; outcomeFilter?: ActionHistoryOutcomeFilter; } /** Filter when scanning all `latest.json` files under strategies. */ export interface ActionFilter { address?: string; actionName?: string; actionType?: ActionType; } /** Zero-value telemetry for a newly registered action. */ export declare function createEmptyTelemetry(): ActionTelemetry; /** Initial persisted snapshot before the first execution. */ export declare function createEmptyLatestState(actionName: string, actionType: ActionType, address: string, decisionMode: DecisionMode): ActionLatestState; //# sourceMappingURL=types.d.ts.map