/** * Per-task `memory` (and the `config.memory_config` that lazily creates it), * plus the `failOnMemoryError` policy. * * Ports `praisonaiagents/task/task.py::initialize_memory` / `store_in_memory` * and the memory-context branch of `agents.py::_prepare_task_prompt`: * * - `config.memory_config` builds a store on first use when the task was given * no `memory` object. * - A task with memory has its output stored after it runs, and recalls related * entries into the next prompt. * - A store that throws appends to `nonFatalErrors` and is otherwise swallowed, * unless `failOnMemoryError` is set, in which case it is re-raised. */ import type { Task } from '../types'; /** The store shape both `Memory` and `Agent`'s memory satisfy. */ export interface TaskMemoryStore { add(content: string, role: 'user' | 'assistant' | 'system', metadata?: Record): Promise | unknown; search(query: string, limit?: number): Promise>; } /** Builds a store from `config.memory_config`; injectable so tests need no backend. */ export type MemoryFactory = (config: Record) => TaskMemoryStore; /** The `memory_config` a task's `config` carries, in either casing. */ export declare function memoryConfigOf(task: Task): Record | undefined; /** * The task's store, creating one from `config.memory_config` on first use. * Assigns the result to `task.memory`, as Python does. */ export declare function initializeTaskMemory(task: Task, factory?: MemoryFactory): TaskMemoryStore | undefined; /** * Store `content` in the task's memory. * * A failure is recorded on `nonFatalErrors` and swallowed, unless * `failOnMemoryError` is set — that flag is the difference between a degraded * run and a failed one. */ export declare function storeTaskOutput(task: Task, content: string, agentName?: string, factory?: MemoryFactory): Promise; /** * Recall entries related to `query` and render them for the prompt. * Returns `''` when the task has no memory or nothing matched. */ export declare function buildMemoryContext(task: Task, query: string, maxItems?: number, factory?: MemoryFactory): Promise;