UNPKG

eve

Version:

Filesystem-first framework for durable backend AI agents that run anywhere.

1 lines • 751 B
function createMemoryInstrumentation(e){return{async execute(t,n){let{hooks:r,rootSessionId:i}=e.resolveContext(),a={...t,rootSessionId:i,sessionId:e.sessionId};await r.publish({...a,type:`memory.operation.started`});try{let i=await e.runInContext({idempotencyKey:t.idempotencyKey,sessionId:e.sessionId,turnId:t.turnId,type:`memory.operation`},n);return await r.publish({...a,outputRecords:i.outputRecords,recordCount:i.recordCount,type:`memory.operation.completed`}),i.value}catch(e){throw await r.publish({...a,error:e,type:`memory.operation.failed`}),e}}}}async function instrumentMemoryOperation(e,t,n){return e===void 0?(await n()).value:await e.execute(typeof t==`function`?t():t,n)}export{createMemoryInstrumentation,instrumentMemoryOperation};