@struktoai/mirage-core
Version:
A Unified Virtual Filesystem For AI Agents
44 lines • 2.15 kB
TypeScript
import type { DiscordAccessor } from '../../accessor/discord.ts';
import { type FileEvent, type JsonValue, type PathSpec } from '../../types.ts';
/**
* Map one Discord gateway dispatch onto mount paths.
*
* The consumer holds the gateway connection, and passes each dispatch's `t`
* with its `d`. Nothing here runs a loop.
*
* A message is a row of `chat.jsonl` in the day its id was minted on, in UTC
* as `readdir` buckets it, so an edit, a delete or a reaction refreshes the day
* the message was posted, never today. Every directory carries a name, and a
* dispatch names a guild and a channel by id only, so each id is resolved once
* through `/guilds/<id>` or `/channels/<id>` and remembered; a channel or guild
* dispatch forgets what it renamed.
*
* A thread is not listed, and its messages are in no day file. What changes is
* the thread's starter message in its parent channel, which carries the
* thread's counts and has the thread's id, so a message in a thread refreshes
* the parent's day of the thread id.
*
* A new message's attachments are created at the names `readdir` gives them.
* An edit or a delete does not say which attachments went with it, so that
* day's `files` directory is UNKNOWN. A channel, member or guild dispatch
* changes a listing's names, so it is UNKNOWN on the listing: `channels`,
* `members`, or the whole mount for a guild, which also fires for every guild
* when the gateway reconnects and so re-inventories what the gap missed; it
* also forgets the guild's channels, since one renamed during the gap kept its
* old name here. A direct message belongs to no guild and maps to nothing.
*
* Mirrors Python `DiscordEventHook` (`core/discord/events.py`).
*/
export declare class DiscordEventHook {
private readonly accessor;
private readonly guilds;
private readonly channels;
constructor(accessor: DiscordAccessor);
private get;
private guildDir;
private channel;
private messages;
private listing;
toEvents(root: PathSpec, eventType: string, payload: JsonValue): Promise<readonly FileEvent[]>;
}
//# sourceMappingURL=events.d.ts.map