/** * Memory file reader — direct read of memory pipeline artifacts (persona.md, * scene_blocks/*.md) from object storage with STS credential management. * * Usage: * const reader = createMemoryFileReader({ endpoint, apiKey, serviceId }); * const content = await reader.read("scene_blocks/cooking-recipes.md"); * * Under the hood: * 1. Fetches STS temporary credentials from the platform (POST /v2/cos/secret) * 2. Caches credentials until they expire (auto-refresh with 2-min buffer) * 3. Signs a COS V5 GET request with the STS credentials * 4. Returns the file content as a string * * Storage backend (currently COS) is an implementation detail — the public * API is intentionally storage-agnostic. */ /** Raw response from platform `POST /v2/cos/secret`. */ export interface CosSecretResponse { CosUrl: string; TmpSecretId: string; TmpSecretKey: string; TmpToken: string; ExpirationTime: string; PathPrefix: string; } export declare class StsCredential { readonly tmpSecretId: string; readonly tmpSecretKey: string; readonly token: string; readonly bucket: string; readonly region: string; readonly prefix: string; readonly expiresAtMs: number; private readonly _host; constructor(data: CosSecretResponse); isValid(bufferMs?: number): boolean; get cosHost(): string; } export interface MemoryFileReaderConfig { endpoint: string; apiKey: string; serviceId: string; timeout?: number; } export declare class StsCredentialManager { private credential; private fetchPromise; private readonly bufferMs; private readonly endpoint; private readonly apiKey; private readonly serviceId; private readonly timeout; constructor(config: MemoryFileReaderConfig, bufferMs?: number); getCredential(): Promise; invalidate(): void; private refresh; } /** * Generate COS V5 Authorization header for a GET request. * Uses Node.js crypto. */ export declare function cosV5Sign(secretId: string, secretKey: string, method: string, path: string, host: string, startTime?: number, endTime?: number): string; export declare class MemoryFileReader { private readonly stsManager; private readonly timeout; constructor(stsManager: StsCredentialManager, timeout?: number); /** * Read a memory file (persona.md, scene_blocks/*.md, …) by relative path. * * @param path Relative path within the memory space, * e.g. "scene_blocks/cooking-recipes.md" or "persona.md". * @returns File content as UTF-8 string. */ read(path: string): Promise; private doGet; } /** * Convenience factory: create a MemoryFileReader that fetches STS credentials * directly from the platform's `POST /v2/cos/secret` endpoint. */ export declare function createMemoryFileReader(config: MemoryFileReaderConfig, opts?: { bufferMs?: number; timeout?: number; }): MemoryFileReader;