/** * Factory and type guards for {@link Memory} records: `createMessageMemory` * stamps a MESSAGE-metadata memory (scope from the explicit `scope` param, * else derived from whether an `agentId` is present), and the `is*Metadata` / * `is*Memory` guards discriminate a record's kind by its `MemoryType` tag so * storage, embedding, and retrieval can branch on it. `isCustomMetadata` is * the catch-all for any type outside the four known * kinds. The types come from `./types` (`types/memory.ts`); this module holds * only the runtime helpers over them. */ import { type CustomMetadata, type DescriptionMetadata, type DocumentMetadata, type FragmentMetadata, type Memory, type MemoryMetadata, type MemoryScope, type MessageMemory, type MessageMetadata } from "./types/memory.js"; import type { Content, UUID } from "./types/primitives.js"; /** * Build a MESSAGE-metadata memory. When `scope` is omitted the historical * defaults apply: `private` with an `agentId`, `shared` without one. Those * defaults are intentional — omit-`agentId` callers (inbound chat, cloud * events, CLI chat) rely on `shared` so a non-owner's own message stays * readable to them and to the agent. Writers that need a tighter tier (e.g. * the `/api/memory/remember` hash-memory route, which stamps `agent-private`) * pass `scope` explicitly instead of the factory guessing for them. */ export declare function createMessageMemory(params: { id?: UUID; entityId: UUID; agentId?: UUID; roomId: UUID; content: Content & { text: string; }; embedding?: number[]; scope?: MemoryScope; }): MessageMemory; export declare function isDocumentMetadata(metadata: MemoryMetadata): metadata is DocumentMetadata; /** * Type guard to check if a memory metadata is a FragmentMetadata * @param metadata The metadata to check * @returns True if the metadata is a FragmentMetadata */ export declare function isFragmentMetadata(metadata: MemoryMetadata): metadata is FragmentMetadata; export declare function isMessageMetadata(metadata: MemoryMetadata): metadata is MessageMetadata; /** * Type guard to check if a memory metadata is a DescriptionMetadata * @param metadata The metadata to check * @returns True if the metadata is a DescriptionMetadata */ export declare function isDescriptionMetadata(metadata: MemoryMetadata): metadata is DescriptionMetadata; export declare function isCustomMetadata(metadata: MemoryMetadata): metadata is CustomMetadata; /** * Memory type guard for document memories */ export declare function isDocumentMemory(memory: Memory): memory is Memory & { metadata: DocumentMetadata; }; /** * Memory type guard for fragment memories */ export declare function isFragmentMemory(memory: Memory): memory is Memory & { metadata: FragmentMetadata; }; export declare function getMemoryText(memory: Memory, defaultValue?: string): string; /** Stamp app-owned records at their trusted persistence boundary. Existing * identity and scope fields remain authoritative; conflicting origins are not * rewritten. Callers must establish app ownership before invoking this helper. */ export declare function stampAppConversationProvenance(agentId: UUID, memory: T): T; /** Honors explicit no-persistence flags before storage-dependent background work. */ export declare function shouldSkipResponseMemoryPersistence(memory: Memory): boolean;