eve
Version:
Filesystem-first framework for durable backend AI agents that run anywhere.
1 lines • 793 B
JavaScript
import{coalesceTurnInputs}from"#harness/messages.js";const COALESCED_DELIVER_FIELDS=[`context`,`inputResponses`,`message`,`outputSchema`,`task`];function coalesceDeliverPayloads(e){if(e.length===0)return{};if(e.length===1)return e[0]??{};let t={},n=[],r=[],i=[],a=[],o={};for(let s of e){n.push(...s.task?.inputRequests??[]),r.push(...s.task?.agentRequests??[]),i.push(...s.task?.authorizationEvents??[]),a.push(...s.task?.views??[]);for(let[e,n]of Object.entries(s))n!==void 0&&(t[e]=n);o=coalesceTurnInputs(o,s)}for(let e of COALESCED_DELIVER_FIELDS)delete t[e];let s={};return n.length>0&&(s.inputRequests=n),r.length>0&&(s.agentRequests=r),i.length>0&&(s.authorizationEvents=i),a.length>0&&(s.views=a),Object.keys(s).length>0&&(t.task=s),Object.assign(t,o)}export{coalesceDeliverPayloads};