eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 1.36 kB
JavaScript
var InMemoryAgentTraceStateStore=class{#e=new Map;#t=new Map;#n=new Map;#r=new Map;#i=new Map;deleteAction(e){this.#t.delete(e)}deleteActionAnchors(e){for(let[t,n]of this.#e)n.sessionId===e&&this.#e.delete(t)}deleteActions(e,t){for(let[n,r]of this.#t)r.sessionId===e&&(t===void 0||r.turnId===t)&&this.#t.delete(n)}deleteInvocation(e){this.#n.delete(e)}deleteInvocations(e,t){for(let[n,r]of this.#n)r.sessionId===e&&(t===void 0||r.turnId===t)&&this.#n.delete(n)}deleteSession(e){this.#r.delete(e)}deleteTurn(e,t){this.#i.delete(turnKey(e,t))}findAction(e,t){return[...this.#t.values()].find(n=>n.sessionId===e&&n.callId===t)}findActionAnchor(e,t,n){return[...this.#e.values()].find(r=>r.sessionId===e&&r.turnId===t&&r.callId===n)}findInvocations(e,t,n){return[...this.#n.values()].filter(r=>(e===void 0||r.sessionId===e)&&(t===void 0||r.turnId===t)&&(n===void 0||r.parentActionCallId===n))}getAction(e){return this.#t.get(e)}getSession(e){return this.#r.get(e)}getTurn(e,t){return this.#i.get(turnKey(e,t))}setAction(e,t){this.#t.set(e,t)}setActionAnchor(e,t){this.#e.set(e,t)}setInvocation(e,t){this.#n.set(e,t)}setSession(e,t){this.#r.set(e,t)}setTurn(e,t,n){this.#i.set(turnKey(e,t),n)}updateTurn(e,t,n){let r=turnKey(e,t),i=this.#i.get(r);i!==void 0&&this.#i.set(r,n(i))}};function turnKey(e,t){return`${e}:${t}`}export{InMemoryAgentTraceStateStore,turnKey};