const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./IyCQvDUH2.js","./X_DUeLZp2.js","./DsQIgu-4.js","./DrKWWDpL.js","./DmLgVuva2.js","./C0bVU7gr2.js","./Ouh6Dj2I2.js","./Dn7LRnjg2.js","./DsanjglN.js","./CbGRcr-D.js","./bG-fsHMS.js","./DTkg6Mnx.js","./DYP3EJMY.js","./DeO5NWhN.js","./DgZn9uJn.js","./CudpqN6Z.js","./CX8DOZuw2.js","./DOqzs8kl2.js","./DIQmuJJZ.js","./D7w7HllH.js","./DB5ifLM-.js","./CxlOpib82.js","./Czb-RtcG.js","./C0nwgWmB.js","./D-eE9s2f.js","./CWxOfblT.js","./DlZwu-Y7.js","./CvFbqtf9.js","./-TjUTcZv2.js","./Y-eU8Aa32.js","./Dg_1c8FK2.js","./CG84LPq-.js","./2PQNgpBd.js","./BmWTAsFW.js","./B5XQZRTz.js","./CVwAhlPZ.js","./BVC3q6GM.js","./B8PRMiR2.js","./BDDiPmhF.js","./BYJC6_MM.js","./Cx_-1PHK2.js","./B_DA9RKE2.js","./DOPTvi6T.js","./CvaH7m0y.js","./O2P-f9sv.js","./BQ9wXJVQ2.js","./OnYyYdSr2.js","./ImGf_A8f.js","./DHbhVvym2.js"])))=>i.map(i=>d[i]);
import{n as e,t}from"./DsQIgu-4.js";import{t as n}from"./DTkg6Mnx.js";import{n as r}from"./Dn7LRnjg2.js";e();async function i(e,n){let{observeBrain:r}=await t(async()=>{let{observeBrain:e}=await import(`./IyCQvDUH2.js`);return{observeBrain:e}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48]),import.meta.url),i=`scope:${e.scopeKind}:${e.scopeId}`,a=`attention:${e.id}`;try{return{success:!0,memoryId:(await r(n,{text:e.content,title:e.content.slice(0,50),type:`discovery`,sourceType:`agent`,origin:`auto-extract`,crossRef:[a,i],provenanceChain:[e.id],...e.agentId?{agent:e.agentId}:{},...e.sessionId?{sourceSessionId:e.sessionId}:{}})).id}}catch(e){return{success:!1,error:{code:`E_CONVERT_FAILED`,message:String(e)}}}}var a={citation:.2,quality:.2,stability:.15,recency:.15,verified:.2,outcome:.1},o=a.citation+a.quality+a.stability+a.recency+a.verified+a.outcome;function s(e){return Math.tanh(e/5)}function c(e){if(!e)return Math.exp(-1);let t=new Date(e.replace(` `,`T`));if(Number.isNaN(t.getTime()))return Math.exp(-1);let n=(Date.now()-t.getTime())/(1e3*60*60*24);return Math.exp(-n/30)}function l(e,t,n){return Math.max(t,Math.min(n,e))}function u(e){let t=s(e.citationCount),n=e.qualityScore??.5,r=e.stabilityScore??.5,i=c(e.createdAt),u=+(e.userVerified>0),d=+(e.outcomeCorrelated>0);return l((a.citation*t+a.quality*n+a.stability*r+a.recency*i+a.verified*u+a.outcome*d)/o,0,1)}var d=.6;function f(e,t=d){let n=s(e.citationCount),r=e.qualityScore??.5,i=e.stabilityScore??.5,o=c(e.createdAt),l=+(e.userVerified>0),f=+(e.outcomeCorrelated>0),p=u(e);return{signals:{citation_count:n,quality_score:r,stability_score:i,recency:o,user_verified:l,outcome_correlated:f},weighted:{citation_count:a.citation*n,quality_score:a.quality*r,stability_score:a.stability*i,recency:a.recency*o,user_verified:a.verified*l,outcome_correlated:a.outcome*f},composite_score:p,threshold:t,decision:p>=t?`promote`:`skip`}}var p=n(`attention-consolidate`),m=.35,h=.1;function g(e){let t=Array.isArray(e.tags)?e.tags.length:0,n=Math.min(1,e.content.trim().length/120),r=Math.min(.3,t*.1),i=Math.min(1,n*.7+r),a=new Date(e.createdAt).toISOString();return{citationCount:0,qualityScore:i,stabilityScore:e.decayScore,createdAt:a,userVerified:0,outcomeCorrelated:0}}function _(e,t,n=Date.now(),r=m,i=h){let a=typeof e.expiresAt==`number`&&e.expiresAt<=n,o=typeof e.decayScore==`number`&&e.decayScore<i;return a||o?`discard`:t>=r?`promote`:`keep`}async function v(e,t={}){let n=t.now??Date.now(),a=t.limit??200,o=t.promoteThreshold??.35,s=t.discardThreshold??.1,c={reviewed:0,promoted:0,kept:0,discarded:0,reviews:[]},l=await r(e),d=await l.findAttention({openOnly:!0,decayThreshold:s,now:n,limit:a});c.reviewed=d.length;for(let t of d){let r=g(t),a=u(r),d=_(t,a,n,o,s),m=null;if(d===`promote`){let n=await i(t,e);n.success&&n.memoryId?(m=n.memoryId,await l.setAttentionStatus(t.id,`consolidated`),c.promoted+=1):(p.warn({attentionId:t.id,err:n.error},`Tier-2 promotion via conduit failed; leaving entry open`),c.kept+=1)}else d===`discard`?c.discarded+=1:c.kept+=1;let h=f(r,o);p.debug({attentionId:t.id,verdict:d,score:a,scopeKind:t.scopeKind,scopeId:t.scopeId,rationale:h.signals},`Tier-2 attention verdict`),c.reviews.push({id:t.id,verdict:d,score:a,scopeKind:t.scopeKind,scopeId:t.scopeId,promotedToId:m})}let m=await l.expireAttention({now:n,decayThreshold:s});return c.discarded=Math.max(c.discarded,m),p.info({reviewed:c.reviewed,promoted:c.promoted,kept:c.kept,discarded:c.discarded},`Tier-2 attention consolidation complete`),c}export{v as consolidateAttention};