import type { TenantId, TopicId } from '../ids/index.js'; import type { PermissionMode } from '../permission/index.js'; /** * State that outlives a turn but belongs to the conversation, not to a turn. * * `PermissionMode` was resolved once per turn and copied into the executor, * so leaving plan mode meant ending the turn and starting a fresh one with * `permissionMode: 'auto'` — discarding the in-flight step and the * tool-schema context with it. The look-around, propose, get-approval, * continue-in-the-SAME-conversation flow could not be built on that, and * `approve_plan` already existed with its approval changing nothing about * the mode. * * Its own record beside the Topic rather than a field on it, with its own * schema version. The Topic record is identity and ownership; this is * mutable session state that changes several times within one conversation * and whose writers are not the Topic's writers. Merging them would make * every mode toggle a CAS conflict against a title rename. */ export interface TopicState { readonly topicId: TopicId; readonly tenantId: TenantId; /** * Compare-and-set counter, starting at 0 for a record's first write. * * Separate from the Topic's `ownerVersion` on purpose — see above. A * host toggling the mode and a manager renaming the topic must not * invalidate each other. */ readonly revision: number; readonly permissionMode: PermissionMode; /** * Messages left for the turn that has not started yet. * * On the same record as the mode and under the same revision, so a host * queueing a message and one toggling the mode cannot silently overwrite * each other — they collide loudly instead, which is what a shared * conversation needs. */ readonly queuedMessages?: readonly import('../message/index.js').Message[]; readonly updatedAt: number; } /** A write whose `revision` no longer matches what is stored. */ export declare class StaleTopicStateError extends Error { readonly details: { topicId: TopicId; expectedRevision: number; actualRevision: number; }; constructor(details: { topicId: TopicId; expectedRevision: number; actualRevision: number; }); } //# sourceMappingURL=state.d.ts.map