import type { JobStateName, WaitingFor } from "./protocol.js"; export type EventKind = /** A job was started (a task, a spawn, a schedule's run). */ "dispatch" /** A job's state changed to one that matters: it waits, finished, failed, was stopped, or started again. */ | "state" /** The user (or the hub's agent) replied to a session. */ | "reply" /** One session messaged another (roost_send). */ | "message" /** A child reported to its parent (handback). */ | "report" /** A watch fired: a session went idle or ended. */ | "notice" /** A run cut short will be started again by itself (M38/M40). */ | "resume" /** A schedule started a run (M39). */ | "schedule" /** A job's record was removed. */ | "removed" /** M44: the concierge told the user something (why: info | need), or answered a question (why: answer). */ | "concierge" /** M47: the task board: a task added, claimed, released, done, dropped, or handed to a session (why says which). */ | "task"; export interface RoostEvent { seq: number; at: number; kind: EventKind; /** The job it is about (the recipient, for a message). */ id: string; name: string; state?: JobStateName; /** For "state": the state it left. */ from?: JobStateName | null; waitingFor?: WaitingFor; /** A short text: the question, the result, the message's first line, the error, the schedule's name. */ text?: string | null; /** Who caused it: a session's name, "user", a schedule's name. */ who?: string | null; /** The job that caused it, when a job did (names can be shared; ids cannot). */ whoId?: string | null; why?: string | null; } /** The log keeps this many events (in memory and in its file). */ export declare const EVENT_LOG_MAX = 1000; /** A text in an event is at most this long. */ export declare const EVENT_TEXT_MAX = 300; export declare function clipText(s: string | null | undefined): string | null; /** The transitions the log keeps: into waiting/done/failed/stopped, and back to work from them. */ export declare function stateMatters(from: JobStateName | null | undefined, to: JobStateName): boolean; export interface EventQuery { /** Events after this seq (the cursor a client holds); absent: the newest. */ after?: number; /** At most this many, oldest first (default 100, at most EVENT_LOG_MAX). */ limit?: number; /** Only this job's. */ id?: string; } /** * An append-only JSON-lines file, the last EVENT_LOG_MAX entries kept. Nothing here is * fsynced: a crash loses the last few lines, and the feed is a convenience, not a record. */ export declare class EventLog { readonly path: string; private events; private seq; private max; /** Lines appended to the file since it was last rewritten. */ private appended; private warn; constructor(path: string, opts?: { max?: number; warn?: (msg: string) => void; }); private load; /** The newest seq (a client's cursor starts here). */ cursor(): number; all(): readonly RoostEvent[]; append(e: Omit & { at?: number; }): RoostEvent; /** * Events after `after` (oldest first), or the newest `limit` when `after` is absent. A * cursor ahead of the log (its file was deleted, the numbering started over) is treated * as absent: the newest `limit`, and the cursor returned is the new one. */ since(q?: EventQuery): { events: RoostEvent[]; cursor: number; }; } /** "3m", "2h", "5d": how long ago, for the hub's /log and the CLI. */ export declare function eventAgo(at: number, now?: number): string; export declare function eventLine(e: RoostEvent): string;