agent-device
Version:
Open source device layer for AI coding agents: a CLI, MCP server, and typed Node.js API to control mobile, web, TV, and desktop apps on devices and simulators, locally or in the cloud.
1 lines • 554 B
JavaScript
function e(e={}){let r=e.ttlMs??3e4,i=e.nowMs??Date.now,a=new Map,o=e=>{let t=n(e);for(let e of a.keys())e.startsWith(t)&&a.delete(e)};return{get(e,n){let r=t(e,n),o=a.get(r);if(o){if(o.expiresAtMs<=i()){a.delete(r);return}return o.value}},set(e,n,o){return a.set(t(e,n),{value:o,expiresAtMs:i()+r}),o},clear(e){o(e)},async invalidateWhile(e,t){o(e);try{return await t()}finally{o(e)}}}}function t(e,t){return[e.platform,e.deviceId,e.variant??``,t.trim().toLowerCase()].join(`\0`)}function n(e){return[e.platform,e.deviceId,``].join(`\0`)}export{e as t};