export type RiskTier = 0 | 1 | 2 | 3 | 4 | 5; export type ActionOutcome = "ok" | "error" | "pending"; export type ActionLedgerEntry = { /** ISO timestamp of when the action started. */ ts: string; koiId?: string; sessionId?: string; kind: "tool"; /** Normalized tool name. */ name: string; /** Short human-readable line describing the action. */ summary: string; /** Conservative risk tier (0 visual/read-only … 5 irreversible). */ riskTier: RiskTier; outcome: ActionOutcome; durationMs: number; /** Paths/URLs produced by the action (for future timeline/rollback UI). */ artifacts?: string[]; /** Hint for a future undo mechanism (e.g. snapshot id, git ref). */ undo?: string; }; export type RiskTierRule = { /** Tier assigned when this rule matches. */ tier: RiskTier; /** Tested against the normalized (lowercase) tool name. */ pattern: RegExp; /** Also test the pattern against a capped snippet of the tool args. */ matchArgs?: boolean; /** Human description shown by `koi ledger --tiers`. */ description: string; }; /** * Built-in conservative classification rules. Exported (and mutable) so * plugins/config can extend or override classification. The highest tier * among all matching rules wins; no match falls back to * {@link DEFAULT_RISK_TIER}. */ export declare const RISK_TIER_RULES: RiskTierRule[]; /** Tier for tools that match no rule — conservative middle ground. */ export declare const DEFAULT_RISK_TIER: RiskTier; /** * Classify a tool call into a conservative risk tier. The highest tier among * all matching rules wins ("when in doubt, rank it riskier"); unknown tools * default to {@link DEFAULT_RISK_TIER}. */ export declare function classifyRiskTier(toolName: string, args?: unknown): RiskTier; /** Build a short single-line human summary for a tool call. */ export declare function summarizeToolCall(toolName: string, args?: unknown, maxLength?: number): string; /** Resolved per call so tests (and tools) can redirect via SKYKOI_STATE_DIR. */ export declare function resolveLedgerFilePath(env?: NodeJS.ProcessEnv): string; /** Append one entry to the JSONL ledger (creates the directory on demand). */ export declare function appendAction(entry: ActionLedgerEntry): Promise; export type ReadActionsOptions = { /** Max entries to return (default 50). */ limit?: number; /** Only entries for this koi. */ koiId?: string; /** Only entries at/after this timestamp (ISO string or Date). */ since?: string | Date; /** Test hook: backwards-read block size in bytes. */ chunkSize?: number; }; /** * Read the most recent ledger entries, newest-first internally but returned * in chronological order (oldest → newest). Reads the file backwards in * chunks so large ledgers never get fully loaded. */ export declare function readActions(options?: ReadActionsOptions): Promise;