UNPKG

eve

Version:

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

1 lines 1.5 kB
const INPUT_CONTENT_ATTRIBUTES=new Set([`agent.channel.delivery.input`,`agent.session.title`,`agent.approval.request`,`ai.documents`,`ai.prompt`,`ai.prompt.system`,`ai.prompt.toolChoice`,`ai.prompt.tools`,`ai.value`,`ai.values`,`gen_ai.input.messages`,`gen_ai.memory.records`,`gen_ai.system_instructions`,`gen_ai.tool.call.arguments`,`gen_ai.tool.definitions`]),OUTPUT_CONTENT_ATTRIBUTES=new Set([`agent.approval.response`,`ai.embedding`,`ai.embeddings`,`ai.ranking`,`ai.response.files`,`ai.response.object`,`ai.response.reasoning`,`ai.response.text`,`ai.response.toolCalls`,`ai.response.tool_calls`,`ai.response.tool_results`,`ai.toolCall.args`,`ai.toolCall.result`,`gen_ai.output.messages`,`gen_ai.tool.call.result`]),INPUT_POLICY_ATTRIBUTE=`agent.trace.content.input`,OUTPUT_POLICY_ATTRIBUTE=`agent.trace.content.output`;function isDeclined(e,t){return!t.recordInputs&&INPUT_CONTENT_ATTRIBUTES.has(e)?!0:!t.recordOutputs&&OUTPUT_CONTENT_ATTRIBUTES.has(e)}function narrowsContentPolicy(e,t){return!t.recordInputs&&e[INPUT_POLICY_ATTRIBUTE]===!0||!t.recordOutputs&&e[OUTPUT_POLICY_ATTRIBUTE]===!0}function exportedAttributeValue(e,t,n){return e===INPUT_POLICY_ATTRIBUTE&&t===!0&&!n.recordInputs||e===OUTPUT_POLICY_ATTRIBUTE&&t===!0&&!n.recordOutputs?!1:t}function withoutDeclinedContent(e,t){let n=Object.keys(e);if(!n.some(e=>isDeclined(e,t))&&!narrowsContentPolicy(e,t))return;let r={};for(let i of n)isDeclined(i,t)||(r[i]=exportedAttributeValue(i,e[i],t));return r}export{withoutDeclinedContent};