@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
16 lines • 1.28 kB
TypeScript
import type { AgentMessage } from "@earendil-works/pi-agent-core";
/** The message's JSON text, or undefined when it cannot be serialized (such a message is never cached). */
export declare function serializeForEstimate(message: AgentMessage): string | undefined;
/**
* The reuse key for the per-message estimate caches, derived from the message's JSON text: it differs
* whenever any estimate-relevant field differs (strings of any length, numbers, booleans, shape), including
* the resident store's in-place token/text swaps. Under Bun the key is the text's length plus a 128-bit
* digest (two seeded wyhash passes), so a cache entry does not hold a second copy of the message's text
* (review of senpi#2884: the text key retained about 1.4x the message's JSON per cached message). Other
* runtimes keep the exact text. The input must be `JSON.stringify` output: Bun.hash maps lone surrogates
* to U+FFFD, and JSON serialization escapes them, so distinct messages never meet that collision.
*/
export declare function estimateCacheKey(serialized: string): string;
export declare function markTransientMessage<T extends AgentMessage>(message: T): T;
export declare function isTransientMessage(message: AgentMessage): boolean;
//# sourceMappingURL=estimate-cache-key.d.ts.map