MCPcopy
hub / github.com/simstudioai/sim / consume

Method consume

apps/sim/lib/core/utils/browser-storage.ts:199–217  ·  view source on GitHub ↗

* Retrieve and consume the stored prompt * @param maxAge - Maximum age of the prompt in milliseconds (default: 24 hours) * @returns The stored prompt or null if not found/expired

(maxAge: number = 24 * 60 * 60 * 1000)

Source from the content-addressed store, hash-verified

197 * @returns The stored prompt or null if not found/expired
198 */
199 static consume(maxAge: number = 24 * 60 * 60 * 1000): string | null {
200 const data = BrowserStorage.getItem<{ prompt: string; timestamp: number } | null>(
201 LandingPromptStorage.KEY,
202 null
203 )
204
205 if (!data || !data.prompt || !data.timestamp) {
206 return null
207 }
208
209 const age = Date.now() - data.timestamp
210 if (age > maxAge) {
211 LandingPromptStorage.clear()
212 return null
213 }
214
215 LandingPromptStorage.clear()
216 return data.prompt
217 }
218
219 /**
220 * Check if there's a stored prompt without consuming it

Callers 1

Calls 2

getItemMethod · 0.80
clearMethod · 0.65

Tested by

no test coverage detected