/** * A `TaskStore` implementation with post-terminal retention semantics. * * Unlike the SDK's `InMemoryTaskStore` — which arms a deletion timer at task * creation and evicts the record after `ttl` regardless of status — this store * treats `ttl` as a *retention window that starts when the task reaches a * terminal state*. Consequences: * * - A non-terminal task (`submitted`/`working`) is immortal: it has no * `expiresAt` and is never evicted, no matter how much time elapses. * - Once a task reaches a terminal state (`completed`/`failed`/`cancelled`), * its retention window opens (`expiresAt = now + ttl`). It stays retrievable * until the window elapses, then is evicted lazily on read or by the periodic * `sweepExpired()` sweep. * * Method contracts and error-message strings mirror `InMemoryTaskStore` so the * only behavioral difference is timer semantics. * * WARNING: builds on the experimental `@modelcontextprotocol/sdk/experimental` * Tasks API, which may change without notice. */ import type { TaskStore, CreateTaskOptions } from '@modelcontextprotocol/sdk/experimental'; import type { Task, RequestId, Request, Result } from '@modelcontextprotocol/sdk/types.js'; export declare class RetentionTaskStore implements TaskStore { private readonly defaultTtl; private tasks; /** * @param defaultTtl Retention window (ms) applied when a task is created * without an explicit `ttl`. `null` means unlimited (no eviction). */ constructor(defaultTtl?: number | null); /** * Generates a unique task ID (16 random bytes as 32 hex chars), matching * `InMemoryTaskStore`. */ private generateTaskId; /** True when a stored task's retention window has elapsed. */ private isExpired; /** * Evict a task and log a distinct eviction message (never a failure). Logged * at `info` so a post-retention `-32602` remains diagnosable under the default * `LOG_LEVEL=info` — this is a benign, expected event, not an error. */ private evict; /** * Look up a live (non-expired) stored task, lazily evicting it if its * retention window has elapsed. */ private getLive; createTask(taskParams: CreateTaskOptions, requestId: RequestId, request: Request, _sessionId?: string): Promise; getTask(taskId: string, _sessionId?: string): Promise; storeTaskResult(taskId: string, status: 'completed' | 'failed', result: Result, _sessionId?: string): Promise; getTaskResult(taskId: string, _sessionId?: string): Promise; updateTaskStatus(taskId: string, status: Task['status'], statusMessage?: string, _sessionId?: string): Promise; listTasks(cursor?: string, _sessionId?: string): Promise<{ tasks: Task[]; nextCursor?: string; }>; /** * Evict every terminal task whose retention window has elapsed. Non-terminal * (immortal) tasks are always spared. Returns the number of tasks dropped. */ sweepExpired(): number; /** Clear all stored tasks (useful for testing or graceful shutdown). */ cleanup(): void; /** Open a terminal task's retention window from now, if a ttl is configured. */ private openRetentionWindow; } //# sourceMappingURL=retention-task-store.d.ts.map