/** * [WHO]: DiscoveryCache - read/write/clear cached discovery results * [FROM]: Depends on node:fs, discovery types (DiscoveryResult) * [TO]: Consumed by core/model-registry.ts for persistence of discovery data * [HERE]: core/model/discovery-cache.ts - filesystem cache for remote model discovery * * Caches DiscoveryResult objects as JSON files in {agentDir}/.cache/discovery/. * Each provider gets its own file: {provider}.json * Supports TTL-based expiration (default 24h). */ import type { DiscoveryResult } from "./discovery.js"; /** * Filesystem-backed cache for discovery results. * * Directory structure: * ``` * {cacheDir}/ * ├── dashscope-coding.json * ├── ollama.json * └── ali-token-plan-openai.json * ``` * * Each file contains a serialized DiscoveryResult with TTL metadata. */ export declare class DiscoveryCache { private cacheDir; constructor(cacheDir: string); /** * Get the filesystem path for a provider's cache file. * Sanitizes provider name to avoid path traversal. */ private providerCachePath; /** * Read a cached discovery result. * Returns undefined if: * - The file doesn't exist * - The file is corrupted (JSON parse error) * - The result has expired (age > TTL) * * @param provider Provider name * @param ttlSeconds Time-to-live in seconds (default: 24h) */ read(provider: string, ttlSeconds?: number): DiscoveryResult | undefined; /** * Write a discovery result to the cache. * Creates the cache directory if it doesn't exist. */ write(result: DiscoveryResult): void; /** * Check if a cache entry exists and is fresh (without reading full content). */ isFresh(provider: string, ttlSeconds?: number): boolean; /** * Remove a single provider's cache file. */ remove(provider: string): void; /** * Clear all cached discovery data by removing the cache directory. */ clear(): void; /** * List all provider names that have cached data (fresh or stale). */ listProviders(): string[]; }