import { NamzuError } from '../../types/errors/index.js'; import type { MemoryId } from '../../types/ids/index.js'; import type { CreateMemoryParams, MemoryIndexEntry, UpdateMemoryParams } from '../../types/memory/index.js'; /** A memory name is a file name and a link target, so it is kept to what is safe as both. */ export declare const MEMORY_NAME_PATTERN: RegExp; export declare const MEMORY_NAME_MAX_LENGTH = 64; /** * Longest name {@link slugifyMemoryName} derives from a title. Shorter than * {@link MEMORY_NAME_MAX_LENGTH} because the name appears twice in an index * line (`- [name](name.md) — description`) inside a 150-character budget; a * derived name that spends it all leaves the description, the only text a * reader judges relevance by, a few words long. */ export declare const DERIVED_MEMORY_NAME_MAX_LENGTH = 32; /** The index file a one-file-per-memory store generates; never a memory's name. */ export declare const MEMORY_INDEX_NAME = "MEMORY"; export declare function isMemoryName(value: unknown): value is string; export declare function assertMemoryName(value: unknown): asserts value is string; /** * The slug a title becomes. Diacritics are folded, everything else outside * `a-z0-9` is a separator, and the result is cut at a word boundary. A title * with no Latin letters or digits at all becomes `memory-note`, which the * caller then suffixes like any other taken name. */ export declare function slugifyMemoryName(text: string): string; /** `base`, or `base-2`, `base-3`… — the first one nobody holds. */ export declare function uniqueMemoryName(base: string, taken: ReadonlySet): string; /** * A save under a name another memory already holds. * * Refused rather than suffixed because an explicit name is a claim about * WHICH memory this is: two records under one name are the duplicate a * caller should have written as an update. The error names the holder so * the caller can do exactly that. */ export declare class MemoryNameConflictError extends NamzuError { readonly memoryName: string; readonly existingId: MemoryId; constructor(name: string, existingId: MemoryId); } /** Why a store refused to write a memory's content. */ export type MemoryContentRejection = 'too_large' | 'nul_byte'; /** * A memory the store would write but could not read back. * * Refused before anything is written: a one-file-per-memory store refuses to * load a directory holding a file it cannot read, so writing one would turn * a single bad save into every later operation failing. */ export declare class MemoryContentRejectedError extends NamzuError { readonly reason: MemoryContentRejection; /** Encoded size of the file that would have been written, when `too_large`. */ readonly bytes?: number; readonly limit?: number; constructor(reason: MemoryContentRejection, details?: { readonly bytes?: number; readonly limit?: number; }); } /** Refuse malformed optional fields before a store writes anything. */ export declare function assertOptionalMemoryFields(params: Pick): void; /** The holder of `name` other than `self`, if any. */ export declare function nameHolder(entries: readonly MemoryIndexEntry[], name: string, self?: MemoryId): MemoryIndexEntry | undefined; /** Copy the optional typed fields onto an entry, leaving absent ones absent. */ export declare function withOptionalFields(entry: MemoryIndexEntry, fields: Pick): MemoryIndexEntry; //# sourceMappingURL=naming.d.ts.map