MCPcopy Create free account
hub / github.com/arctic-cli/interface / cacheSignature

Function cacheSignature

packages/arctic/src/auth/antigravity-oauth/cache.ts:102–131  ·  view source on GitHub ↗
(sessionId: string, text: string, signature: string)

Source from the content-addressed store, hash-verified

100 * Used for Claude models that require signed thinking blocks in multi-turn conversations.
101 */
102export function cacheSignature(sessionId: string, text: string, signature: string): void {
103 if (!sessionId || !text || !signature) return;
104
105 let sessionCache = signatureCache.get(sessionId);
106 if (!sessionCache) {
107 sessionCache = new Map();
108 signatureCache.set(sessionId, sessionCache);
109 }
110
111 // Evict old entries if we're at capacity
112 if (sessionCache.size >= MAX_ENTRIES_PER_SESSION) {
113 const now = Date.now();
114 for (const [key, entry] of sessionCache.entries()) {
115 if (now - entry.timestamp > SIGNATURE_CACHE_TTL_MS) {
116 sessionCache.delete(key);
117 }
118 }
119 // If still at capacity, remove oldest entries
120 if (sessionCache.size >= MAX_ENTRIES_PER_SESSION) {
121 const entries = Array.from(sessionCache.entries()).sort((a, b) => a[1].timestamp - b[1].timestamp);
122 const toRemove = entries.slice(0, Math.floor(MAX_ENTRIES_PER_SESSION / 4));
123 for (const [key] of toRemove) {
124 sessionCache.delete(key);
125 }
126 }
127 }
128
129 const textHash = hashText(text);
130 sessionCache.set(textHash, { signature, timestamp: Date.now() });
131}
132
133/**
134 * Retrieves a cached signature for a given session and text.

Callers 1

cacheThinkingSignaturesFunction · 0.90

Calls 4

hashTextFunction · 0.85
getMethod · 0.45
setMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected