import type { AccessContext } from "../types/access-context.js"; import type { MessageContentSourceSelector } from "../types/database.js"; import type { Memory } from "../types/memory.js"; import type { Content, ContentValue, Media, UUID } from "../types/primitives.js"; export declare const MESSAGE_CONTENT_SEGMENT_VERSION: 1; export declare const MESSAGE_CONTENT_SEGMENT_MAX_BYTES: number; export declare const MESSAGE_CONTENT_PARENT_INLINE_MAX_BYTES: number; export declare const MESSAGE_CONTENT_READ_MAX_SEGMENTS = 3; export declare const MESSAGE_CONTENT_SEGMENT_TABLE = "message_content_segments"; export type MessageContentSourceKind = "message-text" | "attachment-text"; export interface MessageContentSourceDescriptor { [key: string]: ContentValue; kind: MessageContentSourceKind; storage: "segments"; version: typeof MESSAGE_CONTENT_SEGMENT_VERSION; revision: string; sha256: string; byteLength: number; segmentCount: number; /** Hash only: raw attachment identifiers never enter segment rows. */ attachmentIdHash?: string; } export interface MessageContentSegmentMetadata { type: "message-content-segment"; messageId: UUID; sourceKind: MessageContentSourceKind; attachmentIdHash?: string; sourceRevision: string; segmentVersion: typeof MESSAGE_CONTENT_SEGMENT_VERSION; ordinal: number; byteStart: number; byteEnd: number; segmentSha256: string; timestamp: number; } export interface MessageContentProjection { content: Content; segments: Memory[]; } interface ReconstructedMessageContentPage { text: string; start: number; end: number; total: number; revision: string; sourceSha256: string; sliceSha256: string; returnedSegments: number; returnedBytes: number; sourceQueryCount: number; } export declare function hashAttachmentIdForLocator(attachmentId: string): string; /** Exact text exposed by ATTACHMENT reads, without fallback prose. */ export declare function canonicalAttachmentText(attachment: Media): string; export declare function messageContentSegmentId(args: { messageId: UUID; kind: MessageContentSourceKind; revision: string; ordinal: number; attachmentHash?: string; }): UUID; /** Builds the small parent and every immutable segment before publication. */ export declare function buildMessageContentProjection(message: Memory & { id: UUID; }): MessageContentProjection; export declare function isMessageContentSourceDescriptor(value: unknown, expectedKind?: MessageContentSourceKind): value is MessageContentSourceDescriptor; export declare function messageTextSourceDescriptor(content: Content): MessageContentSourceDescriptor | null; export declare function attachmentTextSourceDescriptor(attachment: Media): MessageContentSourceDescriptor | null; /** Finds exactly one committed source descriptor; duplicates fail closed. */ export declare function resolveMessageContentSourceDescriptor(content: Content, selector: MessageContentSourceSelector): MessageContentSourceDescriptor | null; /** * Authorizes a parent at every page read. Segment rows inherit no independent * visibility: a missing participant or a redacted/denied disclosure cannot * return full source text. */ export declare function authorizeMessageContentRead(args: { parent: Memory; authorizedRoomId: UUID; requester: AccessContext; agentId: UUID; participantCurrent: boolean; selector: MessageContentSourceSelector; }): boolean; export declare function messageContentRequiresSegments(content: Content): boolean; export declare function collectMessageContentSegmentIds(messageId: UUID, content: Content): UUID[]; /** Validates adapter-selected rows and returns exactly one UTF-8 byte page. */ export declare function readMessageContentProjection(args: { descriptor: MessageContentSourceDescriptor; segments: Memory[]; messageId: UUID; offset: number; limit: number; sourceQueryCount?: number; }): ReconstructedMessageContentPage; export {};