/** * Your topics, newest activity first: the one shared rule Peek, Ship and Leaf * order topics by (TOPI-10; Miky, 2026-11-06, "Where anything moved"). * * A topic's time is when anything last happened in it, deep: * * - a message or reply in its own conversation (`kind:1111`/`9` with its `A`); * - a change to the topic itself, except tidying it: its `order:` and * `look:` (arranging, a row/card switch), a file taken off its list * (`lists:` = `false`) — a file put on it counts; * - a change to, or a comment on, any file its list holds, and on every file * under one: a listed project's issues, a listed document's pages, any depth * (the newest {@link MAX_CHILDREN} under each); * - a new file under one (an issue filed in a listed project). * * Never, anywhere: a rename (`title`, on the topic or any file; Miky, * 2026-11-09), who is on a file or at what level (`member:

`, `follow:

`, * §11.8) — joining would move a topic up for everyone — and read state * (`kind:30078`). The agent's own writes count like anyone's. * * An event counts only on the file it is on as the fold reads it, never by a * tag alone: a change by its first `a`, in its file's own team (`h`); a * comment by its root, never a crossed one; a new file by its one `a`. * With nothing else, a topic's time is its first record's. * * Every `created_at` is the author's to write, and the relay takes one up to * 15 minutes ahead: each time is capped at the reader's clock, so a * future-dated event cannot pin a topic to the top. * * Two people's orders may differ where a listed file sits in a team only one * of them reads; nothing unreadable is revealed, since each reads as itself. * * The rule takes any set of topics, so an Explore page orders every topic the * reader can open with the same read ({@link readTopicActivity}), and a live * app keeps it current with {@link watchTopicActivity}. * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/each-file-on-a-topic-keeps-its-own-place-and-look.md */ import { type LiveRelay, type SignedEvent } from '@estiva-app/protocol'; import { type QueryFn } from './projection.js'; import { type ReadTopic } from './topics.js'; /** A file whose activity is a topic's: on its list, or under a file on it. */ export interface ActivityFile { /** Its address, `::`. */ address: string; /** Its team, from its root (§6.2), when the reader holds it: a live watch names it. */ folder: string | null; } /** A topic to order, as the reader holds it. */ export interface ActivityTopic { /** Its address. */ address: string; /** Its first record's time (Unix seconds): its time, when nothing has happened in it since. */ createdAt?: number; /** Its team, from its root: a change to it counts only in it, and a live watch names it. */ folder?: string | null; /** The files its list holds. A file under one of them is found by the read. */ files: readonly ActivityFile[]; } /** {@link readTopicActivity}'s answer, and what {@link watchTopicActivity} keeps current. */ export interface TopicActivity { /** Each topic asked for, by address: Unix seconds of the newest thing that happened in it, capped at the reader's clock; 0 when nothing is known. */ at: Map; /** Each topic's files, by address: the listed ones and every file under them. */ files: Map; /** Each topic's team, as asked. */ folders: Map; /** * Each file a topic lists directly (not a file under one), by address: the * comments about it (`kind:1111`, on it as the fold reads it, never by a * crossed tag) that the read already fetched to time its topics, oldest * first. The read asks nothing more for them, so a file holds its newest * comment or few, and none when it has none. {@link watchTopicActivity} * appends each new one in place (TOPI-3). */ comments: Map; } /** {@link ActivityTopic}s from {@link readTopics}' answer: each topic with its resolved list. */ export declare function activityTopics(topics: readonly ReadTopic[]): ActivityTopic[]; /** * Whether an event is news for the topic it is read for: the rule above, * event by event. `topic` is the address of the topic being ordered, so a * change to the topic itself is judged as tidying or not. */ export declare function countsAsActivity(event: SignedEvent, topic: string): boolean; /** Newest first, then by address: the order of a set of topics, from {@link TopicActivity.at}. */ export declare function byActivity(at: ReadonlyMap): (a: string, b: string) => number; /** * Each topic's newest activity (the rule above), for any set of topics the * reader holds — theirs, or every one they can open. * * Reads, whatever the number of topics: one request per level of files under * the listed ones (a project's issues, then each further level of pages), * then the newest few events of each topic's conversation and own changes and * of each file's changes and comments, every target one filter in the same * request (another per {@link MAX_FILTERS_PER_QUERY}). A target whose newest * events are all tidying is asked again from older ones, up to a few rounds. * * Measured 9 Nov 2026 on production over the 47 topics the agent can read * (Miky is in 24 of them): about 1.9 MB in 7 requests, 1 s. Most of it is the * newest text save of a file, which carries the whole text, and the roots of * the issues under listed projects. * * `query` answers each filter as one request would, honouring `limit` and * `until` (the apps' viewer query does). A failed read rejects. */ export declare function readTopicActivity(query: QueryFn, topics: readonly ActivityTopic[], options?: { nowSeconds?: number; }): Promise; /** A live watch's handle. */ export interface ActivityWatch { /** Idempotent. Closes its subscriptions. */ stop(): void; } /** * Keep {@link TopicActivity} current, live: hear every new event that is news * for a topic it holds (the rule above), raise that topic's time, and say so. * A new file under a listed one (an issue filed in a listed project) is news, * and its own activity is heard from then on. * * One REQ for every topic (another per {@link MAX_FILTERS_PER_REQ} filters). * `onActivity` is called with the topic and its new time, after `activity.at` * is raised in place; an event that is not news, or older than what is held, * says nothing. * * A new comment about a file a topic lists directly (one of * `activity.comments`' keys, by the same rule the read uses) is appended to * that file's list in place, and `onComment` is called with the file and the * comment, whether or not it raised a topic's time: an older-dated one, or * one on a topic already newer, still reaches it. One heard twice is kept * and said once. It adds no filter: the watch already asks for them (TOPI-3). * * As {@link watchListedConversations} does, it asks by file alone when given * `namesTeams: relayNamesTeams(relay)` on a relay that lists * `buzz-live-as-stored` (ours), opening once that answer is in. Otherwise * (the default) every filter also names the teams of the topics and their * files, and a file whose team is unknown is not heard from its team. * * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-request-kept-open-hears-what-asking-again-would-return.md */ export declare function watchTopicActivity(relay: Pick, activity: TopicActivity, onActivity: (topic: string, at: number) => void, options?: { /** Unix seconds to hear from. Defaults to now. */ since?: number; /** Whether to name teams; a promise ({@link relayNamesTeams}) holds the REQ until it settles. Defaults to true. */ namesTeams?: boolean | Promise; /** A new comment about a listed file, after it is appended to `activity.comments`. */ onComment?: (file: string, event: SignedEvent) => void; onClosed?: (reason: string) => void; now?: () => number; setTimer?: (run: () => void, ms: number) => unknown; clearTimer?: (timer: unknown) => void; }): ActivityWatch; //# sourceMappingURL=activity.d.ts.map