export type ComponentHealth = "healthy" | "degraded" | "unhealthy" | "disabled" | "unknown"; export interface ComponentHealthStatus { component: string; health: ComponentHealth; updatedAt: string; summary: string; error?: string; } export interface ComponentSystemState { component: string; health: ComponentHealth; updatedAt: string; state: TState; error?: string; } export interface StateStatusProvider { getHealthStatus(): Promise; getSystemState(): Promise; } export interface ScannerRegistrationHealth { address: string; scannerId: string; health: ComponentHealth; /** * Cumulative supervised child restarts since runtime start (external scanners); * 0 for interval/internal scanners or when no supervision source is attached. * Joined from the supervision snapshot in the module — single producer. */ restartCount?: number; /** Supervisor crash-loop cause (last exit summary), present only when the supervisor marked this scanner degraded. */ degradedReason?: string; } export interface ScannerComponentHealthStatus extends ComponentHealthStatus { component: "scanners"; totals: { registered: number; enabled: number; inFlight: number; degraded: number; unhealthy: number; }; scanners: ScannerRegistrationHealth[]; /** * True when the runtime's external scanners never wired (mount/launch threw): * the runtime is running with NO live entry scanners. Joined from the * supervision snapshot; absent/false when scanners wired normally. */ unwired?: boolean; /** Phase that failed when unwired ("mount" | "launch" | "install_launch" | "install_wire"). */ unwiredPhase?: string; } export interface ScannerRegistrationSystemState { address: string; scannerId: string; scheduleMode: "interval" | "external"; health: ComponentHealth; enabled: boolean; initialized: boolean; intervalSeconds: number; inFlight: boolean; /** * When the in-flight scan started, or null when none is running. `inFlight` alone reads the same * for a 200ms scan and one wedged for four minutes on a 15s interval — the age of this stamp is * what separates them. */ inFlightSince: number | null; lastRunStartedAt: number | null; lastRunFinishedAt: number | null; lastRunStatus: string | null; lastRunReason: string | null; lastError: string | null; lastErrorAt: number | null; nextRunAt: number | null; runCount: number; errorCount: number; consecutiveErrorCount: number; /** Cumulative signals emitted across all runs since process start (in-memory; resets on restart). */ signalsProduced: number; /** * Last external-scanner heartbeat (epoch ms) from the intake liveness clock; null for * interval/internal scanners (they never POST) and for an external scanner not yet heard from. */ lastAliveAt: number | null; configVersion: number | null; runtimeUpdatedAt: number | null; config: unknown; state: unknown; } export interface ScannerSystemState extends ComponentSystemState<{ totalRegistered: number; totalEnabled: number; scanners: ScannerRegistrationSystemState[]; }> { component: "scanners"; } export interface DslComponentHealthStatus extends ComponentHealthStatus { component: "dsl"; enabled: boolean; activePositions: number; /** Monitor liveness digest — the key fields of DslSystemState.monitor, for `senpi status`. */ monitor?: { running: boolean; inFlight: boolean; lastTickError: string | null; nextTickAt: number | null; }; } export interface DslSystemState extends ComponentSystemState<{ enabled: boolean; intervalMs: number; preset: string; monitor: { running: boolean; inFlight: boolean; lastTickStartedAt: number | null; lastTickFinishedAt: number | null; lastTickError: string | null; nextTickAt: number | null; tickAttemptCount: number; tickSuccessCount: number; tickErrorCount: number; }; activePositions: unknown[]; positions: unknown[]; }> { component: "dsl"; } export type ActionType = import("../actions/types.js").ActionType; export type DecisionMode = import("../actions/types.js").DecisionMode; export interface ActionRegistrationHealth { address: string; actionName: string; actionType: ActionType; health: ComponentHealth; } export interface ActionComponentHealthStatus extends ComponentHealthStatus { component: "actions"; totals: { registered: number; enabled: number; inFlight: number; degraded: number; unhealthy: number; }; actions: ActionRegistrationHealth[]; } export interface ActionRegistrationSystemState { address: string; actionName: string; actionType: ActionType; decisionMode: DecisionMode; health: ComponentHealth; enabled: boolean; inFlight: boolean; lastRunStartedAt: number | null; lastRunFinishedAt: number | null; lastRunStatus: string | 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[]; config: unknown; } export interface ActionSystemState extends ComponentSystemState<{ totalRegistered: number; totalEnabled: number; actions: ActionRegistrationSystemState[]; }> { component: "actions"; } export type RiskGateStatus = "OPEN" | "COOLDOWN" | "CLOSED" | "N_A"; export type RiskFailureKind = "none" | "timeout" | "transport" | "auth" | "schema" | "empty_data" | "unexpected"; export type RiskSource = "runtime" | "cli"; export type RiskGateId = "daily_loss_halt" | "drawdown_halt" | "consecutive_loss" | "per_asset_cooldown" | "max_entries_day"; /** * Every verdict a gate can report, as a total `Record` over {@link RiskGateStatus} — the one place * the members are spelled out. Parsers that read a gate status off an untrusted payload test * membership here (`Object.hasOwn`) instead of keeping their own list, so adding a status breaks the * build at this declaration rather than silently failing every gate in the new state. */ export declare const RISK_GATE_STATUSES: Record; export declare const RISK_GATE_NAMES: Record; /** Per-gate evaluation result with reliability metadata. */ export interface RiskGateEvaluation { gateId: RiskGateId; gateName: string; status: RiskGateStatus; reason?: string; evaluationOk: boolean; fallbackApplied: boolean; failureKind: RiskFailureKind; source: RiskSource; metrics?: Record; } export interface RiskComponentHealthStatus extends ComponentHealthStatus { component: "risk"; enabled: boolean; eligibility: Exclude; totals: { gatesEvaluated: number; open: number; cooldown: number; closed: number; na: number; fallbackCount: number; failedCount: number; }; gates: RiskGateEvaluation[]; } export interface RiskSystemState extends ComponentSystemState<{ enabled: boolean; eligibility: Exclude; source: RiskSource; checkedAt: string; gates: RiskGateEvaluation[]; }> { component: "risk"; } export type RuntimeLogLevel = "debug" | "info" | "warn" | "error"; export interface RuntimeHealthStatus { runtimeId?: string; runtimeName: string; startedAt: string; generatedAt: string; health: ComponentHealth; logLevel: RuntimeLogLevel; components: { scanners: ScannerComponentHealthStatus; dsl?: DslComponentHealthStatus; actions?: ActionComponentHealthStatus; risk?: RiskComponentHealthStatus; }; } export interface RuntimeSystemState { runtimeId?: string; runtimeName: string; stateDir: string; startedAt: string; generatedAt: string; health: ComponentHealth; logLevel: RuntimeLogLevel; components: { scanners: ScannerSystemState; dsl?: DslSystemState; actions?: ActionSystemState; risk?: RiskSystemState; }; } //# sourceMappingURL=types.d.ts.map