import type { TenantId, TopicId } from '../../types/ids/index.js'; import type { Message } from '../../types/message/index.js'; import type { PermissionMode } from '../../types/permission/index.js'; import { type TopicState } from '../../types/topic/state.js'; export interface TopicStateStore { /** `null` when this topic has never had state written. */ getState(topicId: TopicId, tenantId: TenantId): Promise; /** * Compare-and-set on `revision`, `0` for a first write. * * Rejects a stale revision the way `updateTopic` rejects a stale * `ownerVersion`. Two hosts toggling one conversation's mode is not * hypothetical — a TUI and a webhook on the same topic — and * last-write-wins there silently reopens a mode somebody just closed. */ setPermissionMode(topicId: TopicId, tenantId: TenantId, mode: PermissionMode, opts: { readonly revision: number; }): Promise; /** * Replace the next-run queue, under the same compare-and-set. * * Replace rather than append, so the caller that read the list is the * one that decides what the new one is — an append primitive would let * a caller add to a list it had never seen. */ setQueuedMessages(topicId: TopicId, tenantId: TenantId, messages: readonly Message[], opts: { readonly revision: number; }): Promise; } export declare class InMemoryTopicStateStore implements TopicStateStore { private readonly now; private readonly states; constructor(now?: () => number); getState(topicId: TopicId, tenantId: TenantId): Promise; setPermissionMode(topicId: TopicId, tenantId: TenantId, mode: PermissionMode, opts: { revision: number; }): Promise; setQueuedMessages(topicId: TopicId, tenantId: TenantId, messages: readonly Message[], opts: { revision: number; }): Promise; } export interface DiskTopicStateStoreConfig { /** The session root. State lives under `/topic-state/`. */ readonly rootDir: string; } export declare class DiskTopicStateStore implements TopicStateStore { private readonly config; private readonly now; constructor(config: DiskTopicStateStoreConfig, now?: () => number); private location; getState(topicId: TopicId, tenantId: TenantId): Promise; setPermissionMode(topicId: TopicId, tenantId: TenantId, mode: PermissionMode, opts: { revision: number; }): Promise; setQueuedMessages(topicId: TopicId, tenantId: TenantId, messages: readonly Message[], opts: { revision: number; }): Promise; } //# sourceMappingURL=state.d.ts.map