agentix-cli 0.193.0 → 0.194.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/README.md +1 -1
  2. package/apps/mac-helper/Sources/AgentXHelper/Presence.swift +70 -6
  3. package/apps/mac-helper/Sources/AgentXHelper/PresenceTag.swift +42 -5
  4. package/apps/mac-helper/Sources/AgentXHelper/main.swift +2 -1
  5. package/apps/mac-voice/Sources/AgentXVoice/AgentClient.swift +107 -4
  6. package/apps/mac-voice/Sources/AgentXVoice/Config.swift +0 -9
  7. package/apps/mac-voice/Sources/AgentXVoice/HistoryWindow.swift +3 -2
  8. package/apps/mac-voice/Sources/AgentXVoice/OpenRequests.swift +276 -8
  9. package/apps/mac-voice/Sources/AgentXVoice/RequestsWindow.swift +357 -26
  10. package/apps/mac-voice/Sources/AgentXVoice/SettingsWindow.swift +27 -0
  11. package/apps/mac-voice/Sources/AgentXVoice/StatusMenu.swift +17 -2
  12. package/apps/mac-voice/Sources/AgentXVoice/VoiceSettings.swift +23 -1
  13. package/apps/mac-voice/Sources/AgentXVoice/main.swift +335 -30
  14. package/dist/{App-6TNGC3UR.js → App-HBM52GXI.js} +2 -2
  15. package/dist/{ChatApp-FUDLZ6HZ.js → ChatApp-N4P7M2TD.js} +2 -2
  16. package/dist/{absorb-eval-YSWPPGQF.js → absorb-eval-HRWWPKT3.js} +2 -2
  17. package/dist/{adapter-EEBNOFDS.js → adapter-X6T3YBUB.js} +2 -2
  18. package/dist/{agent-QX2POUEM.js → agent-3B4RMEDI.js} +2 -2
  19. package/dist/{board-dashboard-VVFHNABJ.js → board-dashboard-YCRGMNAT.js} +1405 -5252
  20. package/dist/board-dashboard-YCRGMNAT.js.map +1 -0
  21. package/dist/{chunk-2O72AHK5.js → chunk-2GCPSAXQ.js} +2 -2
  22. package/dist/{chunk-KHKG7H6Q.js → chunk-2KYGPVTX.js} +2 -2
  23. package/dist/chunk-3FZ6WHKX.js +2 -0
  24. package/dist/{chunk-MQRAQJSS.js.map → chunk-3FZ6WHKX.js.map} +1 -1
  25. package/dist/{chunk-HNA4BW47.js → chunk-6NQ7KYJH.js} +2 -2
  26. package/dist/{chunk-Z2NYUCTE.js → chunk-7L54Z4EH.js} +2 -2
  27. package/dist/{chunk-EH7Y2W77.js → chunk-BOCLWYWL.js} +2 -2
  28. package/dist/chunk-F2FJXKDG.js +7 -0
  29. package/dist/{chunk-DS2ZIVIH.js.map → chunk-F2FJXKDG.js.map} +1 -1
  30. package/dist/{chunk-OYXB6KZX.js → chunk-F3CMNSON.js} +2 -2
  31. package/dist/{chunk-52NME3AU.js → chunk-FO762MEC.js} +2 -2
  32. package/dist/{chunk-AAL5WIXB.js → chunk-HNZEXUNM.js} +2 -2
  33. package/dist/{chunk-H5XBQWAI.js → chunk-HOZZUN47.js} +2 -2
  34. package/dist/chunk-I45E5TLK.js +934 -0
  35. package/dist/chunk-I45E5TLK.js.map +1 -0
  36. package/dist/{chunk-Q7ZPW55P.js → chunk-K2BEV3BD.js} +2 -2
  37. package/dist/{chunk-QTBFMRJ2.js → chunk-KE6BF4ZJ.js} +2 -2
  38. package/dist/{chunk-DACZSUCN.js → chunk-KXJRXRSD.js} +2 -2
  39. package/dist/{chunk-TDZDIDFG.js → chunk-LQIF2OHS.js} +2 -2
  40. package/dist/chunk-M2E3CNFS.js +38 -0
  41. package/dist/chunk-M2E3CNFS.js.map +1 -0
  42. package/dist/{chunk-22WO5X4L.js → chunk-MB5CBY2C.js} +106 -106
  43. package/dist/chunk-MB5CBY2C.js.map +1 -0
  44. package/dist/{chunk-JGZ6CA5L.js → chunk-MC3ZZA5G.js} +2 -2
  45. package/dist/{chunk-PSP3NAFU.js → chunk-OEG476JY.js} +79 -76
  46. package/dist/chunk-OEG476JY.js.map +1 -0
  47. package/dist/{chunk-6ZAQ3IT5.js → chunk-P6WSD2UR.js} +23 -23
  48. package/dist/chunk-P6WSD2UR.js.map +1 -0
  49. package/dist/{chunk-GLYBXXO7.js → chunk-PMSL4A5Y.js} +3 -3
  50. package/dist/{chunk-VK2TW3RL.js → chunk-PO2SORKY.js} +2 -2
  51. package/dist/{chunk-N56EHPTR.js → chunk-PX7PWXBI.js} +2 -2
  52. package/dist/{chunk-EI3TZ52P.js → chunk-RW5FKJRE.js} +2 -2
  53. package/dist/{chunk-462FRP7L.js → chunk-S42KBXNO.js} +332 -319
  54. package/dist/chunk-S42KBXNO.js.map +1 -0
  55. package/dist/{chunk-6FUWODBV.js → chunk-UOIWIVU3.js} +2 -2
  56. package/dist/{chunk-2VQ3VKBR.js → chunk-VX4PSOKU.js} +2 -2
  57. package/dist/{chunk-FEXG2PKQ.js → chunk-XH36J3Z2.js} +2 -2
  58. package/dist/{chunk-MQV3IU6F.js → chunk-ZALVAXQ4.js} +2 -2
  59. package/dist/cli.js +1 -1
  60. package/dist/{client-5USANRIL.js → client-YN3T56NM.js} +2 -2
  61. package/dist/{config-N7DHUZMH.js → config-G7T3TMWE.js} +2 -2
  62. package/dist/{config-mutate-OVUXNS5X.js → config-mutate-6CRKZQVQ.js} +2 -2
  63. package/dist/config-mutator-7VS3J5BY.js +2 -0
  64. package/dist/{contributions-LTDE6UOQ.js → contributions-6VZ4OXJ5.js} +2 -2
  65. package/dist/{doctor-C3DTKR7C.js → doctor-GFZZTK7C.js} +2 -2
  66. package/dist/{follow-up-tool-NCFOTJ5Y.js → follow-up-tool-NVP56W7E.js} +2 -2
  67. package/dist/{hub-F3X7NL4B.js → hub-B434CABZ.js} +2 -2
  68. package/dist/index.d.ts +38 -6
  69. package/dist/index.js +1 -1
  70. package/dist/{program-6HWZZ2D3.js → program-IDRN5TAM.js} +238 -238
  71. package/dist/program-IDRN5TAM.js.map +1 -0
  72. package/dist/{promote-FSOPSHJ4.js → promote-3P6PGJOW.js} +2 -2
  73. package/dist/{query-UDRKDTSB.js → query-E4V7TS5S.js} +2 -2
  74. package/dist/{query-settings-DJGEGG62.js → query-settings-C5UBKJMN.js} +2 -2
  75. package/dist/{registry-AVGT5KPR.js → registry-IG324PR3.js} +2 -2
  76. package/dist/{request-planner-SAQX26AR.js → request-planner-G6IAUMSE.js} +2 -2
  77. package/dist/{review-candidates-67MPNU42.js → review-candidates-ZL2SJXWC.js} +2 -2
  78. package/dist/{routing-7DUO5PI7.js → routing-2IBIZYQU.js} +2 -2
  79. package/dist/schedule-tool-QCTT2R3B.js +2 -0
  80. package/dist/{scheduler-3IADVHIN.js → scheduler-ZGB7IKZQ.js} +2 -2
  81. package/dist/{seat-YWSYQBCW.js → seat-CFY7LMPS.js} +2 -2
  82. package/dist/{select-PA7AHZ3W.js → select-MU52ACKG.js} +2 -2
  83. package/dist/self-ELWZIMVY.js +2 -0
  84. package/dist/{set-enabled-DD6L2ZQ6.js → set-enabled-XRNSYEI3.js} +2 -2
  85. package/dist/{sprint-tool-PKJA6LYF.js → sprint-tool-E4MABD2N.js} +2 -2
  86. package/dist/{tool-WJ72TBMV.js → tool-V5Z4KWK7.js} +2 -2
  87. package/dist/{tool-PJSLWK45.js → tool-W6M7GYRZ.js} +2 -2
  88. package/dist/{tool-KOGZBOCR.js → tool-ZYVT4VUU.js} +2 -2
  89. package/dist/{wiki-HQBMWH23.js → wiki-VP6XRWIS.js} +2 -2
  90. package/dist/wiki-enrich-LUFXPUYY.js +2 -0
  91. package/package.json +1 -1
  92. package/dist/board-dashboard-VVFHNABJ.js.map +0 -1
  93. package/dist/chunk-22WO5X4L.js.map +0 -1
  94. package/dist/chunk-462FRP7L.js.map +0 -1
  95. package/dist/chunk-6ZAQ3IT5.js.map +0 -1
  96. package/dist/chunk-BKTKJNCR.js +0 -36
  97. package/dist/chunk-BKTKJNCR.js.map +0 -1
  98. package/dist/chunk-DS2ZIVIH.js +0 -7
  99. package/dist/chunk-MQRAQJSS.js +0 -2
  100. package/dist/chunk-PSP3NAFU.js.map +0 -1
  101. package/dist/chunk-RDENYWNG.js +0 -898
  102. package/dist/chunk-RDENYWNG.js.map +0 -1
  103. package/dist/config-mutator-OK7CDCHW.js +0 -2
  104. package/dist/program-6HWZZ2D3.js.map +0 -1
  105. package/dist/schedule-tool-LZOW5SVQ.js +0 -2
  106. package/dist/self-KACQLLDA.js +0 -2
  107. package/dist/wiki-enrich-7RPM5DQF.js +0 -2
  108. /package/dist/{App-6TNGC3UR.js.map → App-HBM52GXI.js.map} +0 -0
  109. /package/dist/{ChatApp-FUDLZ6HZ.js.map → ChatApp-N4P7M2TD.js.map} +0 -0
  110. /package/dist/{absorb-eval-YSWPPGQF.js.map → absorb-eval-HRWWPKT3.js.map} +0 -0
  111. /package/dist/{adapter-EEBNOFDS.js.map → adapter-X6T3YBUB.js.map} +0 -0
  112. /package/dist/{agent-QX2POUEM.js.map → agent-3B4RMEDI.js.map} +0 -0
  113. /package/dist/{chunk-2O72AHK5.js.map → chunk-2GCPSAXQ.js.map} +0 -0
  114. /package/dist/{chunk-KHKG7H6Q.js.map → chunk-2KYGPVTX.js.map} +0 -0
  115. /package/dist/{chunk-HNA4BW47.js.map → chunk-6NQ7KYJH.js.map} +0 -0
  116. /package/dist/{chunk-Z2NYUCTE.js.map → chunk-7L54Z4EH.js.map} +0 -0
  117. /package/dist/{chunk-EH7Y2W77.js.map → chunk-BOCLWYWL.js.map} +0 -0
  118. /package/dist/{chunk-OYXB6KZX.js.map → chunk-F3CMNSON.js.map} +0 -0
  119. /package/dist/{chunk-52NME3AU.js.map → chunk-FO762MEC.js.map} +0 -0
  120. /package/dist/{chunk-AAL5WIXB.js.map → chunk-HNZEXUNM.js.map} +0 -0
  121. /package/dist/{chunk-H5XBQWAI.js.map → chunk-HOZZUN47.js.map} +0 -0
  122. /package/dist/{chunk-Q7ZPW55P.js.map → chunk-K2BEV3BD.js.map} +0 -0
  123. /package/dist/{chunk-QTBFMRJ2.js.map → chunk-KE6BF4ZJ.js.map} +0 -0
  124. /package/dist/{chunk-DACZSUCN.js.map → chunk-KXJRXRSD.js.map} +0 -0
  125. /package/dist/{chunk-TDZDIDFG.js.map → chunk-LQIF2OHS.js.map} +0 -0
  126. /package/dist/{chunk-JGZ6CA5L.js.map → chunk-MC3ZZA5G.js.map} +0 -0
  127. /package/dist/{chunk-GLYBXXO7.js.map → chunk-PMSL4A5Y.js.map} +0 -0
  128. /package/dist/{chunk-VK2TW3RL.js.map → chunk-PO2SORKY.js.map} +0 -0
  129. /package/dist/{chunk-N56EHPTR.js.map → chunk-PX7PWXBI.js.map} +0 -0
  130. /package/dist/{chunk-EI3TZ52P.js.map → chunk-RW5FKJRE.js.map} +0 -0
  131. /package/dist/{chunk-6FUWODBV.js.map → chunk-UOIWIVU3.js.map} +0 -0
  132. /package/dist/{chunk-2VQ3VKBR.js.map → chunk-VX4PSOKU.js.map} +0 -0
  133. /package/dist/{chunk-FEXG2PKQ.js.map → chunk-XH36J3Z2.js.map} +0 -0
  134. /package/dist/{chunk-MQV3IU6F.js.map → chunk-ZALVAXQ4.js.map} +0 -0
  135. /package/dist/{client-5USANRIL.js.map → client-YN3T56NM.js.map} +0 -0
  136. /package/dist/{config-N7DHUZMH.js.map → config-G7T3TMWE.js.map} +0 -0
  137. /package/dist/{config-mutate-OVUXNS5X.js.map → config-mutate-6CRKZQVQ.js.map} +0 -0
  138. /package/dist/{config-mutator-OK7CDCHW.js.map → config-mutator-7VS3J5BY.js.map} +0 -0
  139. /package/dist/{contributions-LTDE6UOQ.js.map → contributions-6VZ4OXJ5.js.map} +0 -0
  140. /package/dist/{doctor-C3DTKR7C.js.map → doctor-GFZZTK7C.js.map} +0 -0
  141. /package/dist/{follow-up-tool-NCFOTJ5Y.js.map → follow-up-tool-NVP56W7E.js.map} +0 -0
  142. /package/dist/{hub-F3X7NL4B.js.map → hub-B434CABZ.js.map} +0 -0
  143. /package/dist/{promote-FSOPSHJ4.js.map → promote-3P6PGJOW.js.map} +0 -0
  144. /package/dist/{query-UDRKDTSB.js.map → query-E4V7TS5S.js.map} +0 -0
  145. /package/dist/{query-settings-DJGEGG62.js.map → query-settings-C5UBKJMN.js.map} +0 -0
  146. /package/dist/{registry-AVGT5KPR.js.map → registry-IG324PR3.js.map} +0 -0
  147. /package/dist/{request-planner-SAQX26AR.js.map → request-planner-G6IAUMSE.js.map} +0 -0
  148. /package/dist/{review-candidates-67MPNU42.js.map → review-candidates-ZL2SJXWC.js.map} +0 -0
  149. /package/dist/{routing-7DUO5PI7.js.map → routing-2IBIZYQU.js.map} +0 -0
  150. /package/dist/{schedule-tool-LZOW5SVQ.js.map → schedule-tool-QCTT2R3B.js.map} +0 -0
  151. /package/dist/{scheduler-3IADVHIN.js.map → scheduler-ZGB7IKZQ.js.map} +0 -0
  152. /package/dist/{seat-YWSYQBCW.js.map → seat-CFY7LMPS.js.map} +0 -0
  153. /package/dist/{select-PA7AHZ3W.js.map → select-MU52ACKG.js.map} +0 -0
  154. /package/dist/{self-KACQLLDA.js.map → self-ELWZIMVY.js.map} +0 -0
  155. /package/dist/{set-enabled-DD6L2ZQ6.js.map → set-enabled-XRNSYEI3.js.map} +0 -0
  156. /package/dist/{sprint-tool-PKJA6LYF.js.map → sprint-tool-E4MABD2N.js.map} +0 -0
  157. /package/dist/{tool-WJ72TBMV.js.map → tool-V5Z4KWK7.js.map} +0 -0
  158. /package/dist/{tool-PJSLWK45.js.map → tool-W6M7GYRZ.js.map} +0 -0
  159. /package/dist/{tool-KOGZBOCR.js.map → tool-ZYVT4VUU.js.map} +0 -0
  160. /package/dist/{wiki-HQBMWH23.js.map → wiki-VP6XRWIS.js.map} +0 -0
  161. /package/dist/{wiki-enrich-7RPM5DQF.js.map → wiki-enrich-LUFXPUYY.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as _,b as F,c as K,d as z,e as J}from"./chunk-JTFCU5LH.js";import{a as j,b as I,c as Y,d as V,e as B,j as G}from"./chunk-HNA4BW47.js";import{a as H}from"./chunk-LUOW2YHY.js";import{y as N,z as ot}from"./chunk-KHKG7H6Q.js";import{h as Q}from"./chunk-QUFIUXMQ.js";import{b as E,c as L}from"./chunk-AHWWJ7AF.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as R}from"path";import{execSync as ct}from"child_process";var ht="haiku",dt="sonnet",pt=.8;function mt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function _t(e,r,o,t={}){let c=t.selectorModel??ht,l=t.synthModel??dt,m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=R(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||mt(r,o,p,u)>=pt){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?F(t.notes):void 0,y=await J(e,P?gt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:_(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+yt(e,p.sharedPool,h,n),T=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(wt(e,it,m,h),c,i),A=bt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-T,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-T;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),U="";try{U=await Z(kt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:U.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Rt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(ut(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function gt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>_(o)?r.read(o):e.read(o)}}function ut(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var ft=150;function yt(e,r,o,t){return r.length===0?"":`
1
+ import{a as _,b as F,c as K,d as z,e as J}from"./chunk-JTFCU5LH.js";import{a as j,b as I,c as Y,d as V,e as B,j as G}from"./chunk-6NQ7KYJH.js";import{a as H}from"./chunk-LUOW2YHY.js";import{y as N,z as ot}from"./chunk-2KYGPVTX.js";import{h as Q}from"./chunk-QUFIUXMQ.js";import{b as E,c as L}from"./chunk-AHWWJ7AF.js";import{readFileSync as lt,existsSync as X}from"fs";ot();import{resolve as R}from"path";import{execSync as ct}from"child_process";var ht="haiku",dt="sonnet",pt=.8;function mt(e,r,o,t){if(t.size===0)return 0;let c=e.listArticles(r||"").map(l=>l.path).filter(l=>!l.includes("/_versions/"));return c.length===0&&(c=o.sharedPool.map(l=>l.path)),c.length===0?0:c.filter(l=>t.has(l)).length/c.length}async function _t(e,r,o,t={}){let c=t.selectorModel??ht,l=t.synthModel??dt,m=t.maxCandidates??3,g=t.maxHops??2,d=t.maxArticles??8,i=t.timeoutMs??6e4,s=t.log??console.error.bind(console,"[wiki-query]"),h=t.messagePath?.length?t.messagePath:void 0,n=t.graphWeight??W,a=R(r.baseDir,"_index.md"),p=tt(r,o,t.shared),b=t.method??"catalog";if(b!=="catalog"){let u=z(r,t.shared);if(b==="summaries"||mt(r,o,p,u)>=pt){let f=t.summaries??K,P=t.notes&&o&&t.notes.owner===o?F(t.notes):void 0,y=await J(e,P?gt(p,P):p,P?new Map([...u,...P.summaries]):u,{...f,navigatorModel:t.selectorModel??f.navigatorModel,answerModel:t.synthModel??f.answerModel},{call:t.call??H,fetch:t.fetch,timeoutMs:i,log:s}),$=y.picked.map(w=>({title:w.meta.title,path:w.path,type:_(w.path)?"note":w.meta.type,hop:w.hop}));return{answer:y.answer,citations:y.status==="ok"?$.map(({hop:w,...v})=>v):[],candidates:$.filter(w=>w.hop===0).map(({title:w,path:v})=>({title:w,path:v})),walked:$,status:y.status,method:"summaries",basis:y.basis,live:y.live,liveAsked:y.liveAsked,trace:y.trace,...y.error?{error:y.error}:{}}}}if(!X(a)&&p.sharedPool.length===0)return M("no-catalog",e,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let it=(X(a)?lt(a,"utf-8"):"")+yt(e,p.sharedPool,h,n),T=Date.now(),A=[],S="";try{let u=await nt(e,p.pool,o,m,h,n);u?(A=u,S=`[wiki-rerank seat] ${u.map(f=>f.title).join(" | ")}`):(S=await Z(wt(e,it,m,h),c,i),A=bt(S))}catch(u){return s("selector failed:",u?.message),{...M("error",e,`Selector: ${u?.message||"unknown"}`),trace:{selectorMs:Date.now()-T,synthesisMs:0,selectorOutput:S}}}let x=Date.now()-T;if(A.length===0)return{...M("no-candidates",e,"Selector returned no candidates."),trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let C=rt(A,p,g,d);if(C.length===0)return{...M("no-candidates",e,"Candidates did not resolve to readable articles."),candidates:A,trace:{selectorMs:x,synthesisMs:0,selectorOutput:S}};let D=Date.now(),U="";try{U=await Z(kt(e,C),l,i*2)}catch(u){return s("synthesis failed:",u?.message),{...M("error",e,`Synthesis: ${u?.message||"unknown"}`),candidates:A,walked:C.map(f=>({title:f.meta.title,path:f.path,type:f.meta.type,hop:f.hop??0})),trace:{selectorMs:x,synthesisMs:Date.now()-D,selectorOutput:S}}}let st=Date.now()-D;return{answer:U.trim(),citations:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type})),candidates:A,walked:C.map(u=>({title:u.meta.title,path:u.path,type:u.meta.type,hop:u.hop??0})),status:"ok",trace:{selectorMs:x,synthesisMs:st,selectorOutput:S}}}async function Rt(e,r,o,t={}){let c=t.maxCandidates??3,l=t.graphWeight??W,m=t.messagePath?.length?t.messagePath:void 0,g=t.pool??q(r);if(g.length===0||!e.trim())return[];let d=await nt(e,g,o,c,m,l,t.stage??"retrieve");if(!d){let i=new Set(L(e,E(g.map(at))).map(s=>s.docIndex));d=O(e,g,m,l).filter(s=>i.has(s)).slice(0,c).map(s=>({title:g[s].title,path:g[s].path}))}return d.length===0?[]:rt(d,tt(r,o),t.maxHops??1,t.maxArticles??6)}function q(e){try{return(e.rebuildIndex().articles??[]).filter(r=>r.path&&!r.path.includes("/_versions/"))}catch{return[]}}function M(e,r,o){return{answer:"",citations:[],candidates:[],walked:[],status:e,error:o}}function tt(e,r,o=[]){let t=new Map,c=[];for(let i of e.listArticles(r||""))t.set(i.meta.title.toLowerCase(),i.path),c.push({path:i.path,related:i.meta.related??[],lastUpdated:i.meta.lastUpdated??""});let l=[],m=new Map;for(let i of o)if(i.store.baseDir!==e.baseDir){m.set(i.id,i);for(let s of i.store.listArticles(r||"")){if(s.path.includes("/_versions/")||i.skip?.(s.path))continue;let h=`@${i.id}/${s.path}`;l.push(ut(s,h)),c.push({path:h,related:s.meta.related??[],lastUpdated:s.meta.lastUpdated??""});let n=s.meta.title.toLowerCase();t.has(n)||t.set(n,h)}}let g=new Map;if(m.size>0)for(let i of[...c].sort((s,h)=>h.lastUpdated.localeCompare(s.lastUpdated)))for(let s of i.related){let h=s.toLowerCase(),n=g.get(h)??[];n.includes(i.path)||n.push(i.path),g.set(h,n)}let d;return{backlinks:g,readable:new Set(c.map(i=>i.path)),get pool(){return d??=[...q(e),...l]},sharedPool:l,titleIndex:t,read(i){let s=i.match(/^@([^/]+)\/(.+)$/),h=s?m.get(s[1]):void 0;if(s&&!h)return null;let n=h?.store??e,a=s?s[2]:i,p=r?n.readArticleAs(a,r):n.readArticle(a);return p?{...p,path:i}:null},links(i){let s=(i.meta.related??[]).map(a=>t.get(a.toLowerCase())).filter(a=>!!a),h=[i.meta.title,...i.meta.aliases??[]].map(a=>a.toLowerCase()),n=[...new Set(h.flatMap(a=>g.get(a)??[]))].filter(a=>a!==i.path).slice(0,et);return[...new Set([...s,...n])].filter(a=>a!==i.path)}}}function gt(e,r){return{...e,pool:[...e.pool,...r.pool],readable:new Set([...e.readable,...r.pool.map(o=>o.path)]),read:o=>_(o)?r.read(o):e.read(o)}}function ut(e,r){return{path:r,title:e.meta.title,type:e.meta.type,related:e.meta.related,tags:e.meta.tags||[],owner:e.meta.owner,access:e.meta.access,sharedWith:e.meta.sharedWith,aliases:[e.meta.title.toLowerCase(),...(e.meta.aliases??[]).map(o=>o.toLowerCase())],backlinks:0,sources:e.meta.sources,lastUpdated:e.meta.lastUpdated,graphPath:e.meta.graphPath}}var ft=150;function yt(e,r,o,t){return r.length===0?"":`
2
2
 
3
3
  ## Shared wiki (other agents' articles)
4
4
 
@@ -51,5 +51,5 @@ ${o}
51
51
 
52
52
  Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. When two articles disagree, prefer the one updated more recently, and say which agent's page and date the answer comes from. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
53
53
 
54
- Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function bt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=R(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=R(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:Q(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Ot(e){try{let{loadDaemonConfig:r}=await import("./config-N7DHUZMH.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,dt as b,pt as c,_t as d,Rt as e,q as f,ft as g,W as h,O as i,Ot as j};
55
- //# sourceMappingURL=chunk-GLYBXXO7.js.map
54
+ Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function bt(e){let r=e.match(/\[[\s\S]*?\]/);if(!r)return[];try{let o=JSON.parse(r[0]);return Array.isArray(o)?o.filter(t=>t&&typeof t.title=="string"&&typeof t.path=="string").map(t=>({title:t.title,path:t.path})):[]}catch{return[]}}async function Z(e,r,o){let{writeFileSync:t,mkdirSync:c,rmSync:l}=await import("fs"),{tmpdir:m}=await import("os"),g=R(m(),`agentx-wiki-query-${process.pid}`);c(g,{recursive:!0});let d=R(g,`prompt-${Date.now()}.txt`);t(d,e);try{let i=`cat '${d}' | claude -p - --output-format json --max-turns 1 --model ${r} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,s=ct(i,{env:Q(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let h=JSON.parse(s);return String(h.result||h.content||"")}catch{return s}}finally{try{l(d,{force:!0})}catch{}}}async function Ot(e){try{let{loadDaemonConfig:r}=await import("./config-G7T3TMWE.js");return r(e).wiki.query.shared}catch{return!0}}export{ht as a,dt as b,pt as c,_t as d,Rt as e,q as f,ft as g,W as h,O as i,Ot as j};
55
+ //# sourceMappingURL=chunk-PMSL4A5Y.js.map
@@ -1,4 +1,4 @@
1
- import{a as pe}from"./chunk-MQRAQJSS.js";import{a as Ct}from"./chunk-GV7S5BAX.js";import{c as Ft}from"./chunk-SZDACK6O.js";import{b as Le}from"./chunk-AFRHKA7B.js";import{b as Ht,c as Bt}from"./chunk-VJVXEVZ7.js";import{b as jt,e as Mt,f as Et,i as _t,k as Lt,l as Ut,r as Kt}from"./chunk-JGZ6CA5L.js";import{b as Ot,d as Nt,e as Dt}from"./chunk-5ONH4ITT.js";import{e as Pt,g as Tt,h as Wt,i as _e}from"./chunk-JRAG37V5.js";import{y as St,z as Ir}from"./chunk-KHKG7H6Q.js";import{b as $t,f as br}from"./chunk-72SZI2UW.js";import{a as te,b as xt}from"./chunk-A7JSRDJL.js";import{a as At,b as Ee,d as Ce,e as Rt,f as Fe}from"./chunk-BERWTVG2.js";import{c as It,d as vt}from"./chunk-AHWWJ7AF.js";import{ea as Me,pa as kr}from"./chunk-6ZAQ3IT5.js";import{j as je,r as yr}from"./chunk-UEEB3UTU.js";import{existsSync as vr,mkdirSync as qt,readFileSync as $r,writeFileSync as Sr,renameSync as Ar}from"fs";import{resolve as Jt,dirname as Rr}from"path";var zt=class{filePath;log;constructor(e={}){let t=e.baseDir??Jt(process.cwd(),".agentx");this.filePath=Jt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),qt(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!vr(this.filePath))return{version:1,overrides:{}};try{let e=$r(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){qt(Rr(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;Sr(t,JSON.stringify(e,null,2)),Ar(t,this.filePath)}get(e,t,r){let s=this.load().overrides[this.key(e,t,r)];if(s&&!(s.expiresAt&&Date.parse(s.expiresAt)<Date.now()))return s}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),r={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(r.channel,r.chatId,r.accountId)]=r,this.save(t),r}remove(e,t,r){let o=this.load(),s=this.key(e,t,r);return s in o.overrides?(delete o.overrides[s],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),s=o.overrides[this.key(e,t,r)];if(!s||!s.summary||s.summaryConsumedAt)return;let a=s.summary;return s.summaryConsumedAt=new Date().toISOString(),this.save(o),a}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(r=>!r.expiresAt||Date.parse(r.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(r=>r.toAgent===e),outgoing:t.filter(r=>r.fromAgent===e)}}};import{readFileSync as Zt,writeFileSync as Ue,appendFileSync as Wr,mkdirSync as Or,existsSync as Xt,statSync as Nr}from"fs";import{resolve as fe}from"path";var Yt="[Agent Memory \u2014 persistent facts from past conversations]",xr=2400;function Gt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Pr(n,e=Date.now()){let t=Nt(n,e),r=n.undated?"UNVERIFIED (never checked) ":Gt(t,Pt(n.verifiedAt,e));return{line:`- [wiki ${n.id}] ${r}${n.subject} \xB7 ${n.attribute}: ${n.value} (${n.source}, checked ${n.verifiedAt.slice(0,10)} by ${n.verifiedBy})`,unverified:t}}function Tr(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId;if(te(n.content))return{line:`- [${n.category}] ${xt}${n.content} (${r}, ${n.source.date})`,unverified:!0};let o=Wt(n,e);return{line:`- [${n.category}] ${Gt(o,Tt(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function Vt(n,e=[],t=Date.now()){let r=[],o=new Set,s=Yt.length,a=!1;for(let i of n){let d=e.length>0?Dt(i.content,e):null,l,c,p=d&&Date.parse(i.createdAt)>Date.parse(d.verifiedAt)&&!i.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!p){if(o.has(d.id))continue;o.add(d.id),l=Pr(d,t),c=d.id}else l=Tr(i,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?_e.length:0;if(s+f+l.line.length>xr)break;r.push({fact:i,...l,...c?{wikiRef:c}:{}}),s+=f+l.line.length,f&&(a=!0)}return r}function Qt(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[_e]:[];return[Yt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
1
+ import{a as pe}from"./chunk-3FZ6WHKX.js";import{a as Ct}from"./chunk-GV7S5BAX.js";import{c as Ft}from"./chunk-SZDACK6O.js";import{b as Le}from"./chunk-AFRHKA7B.js";import{b as Ht,c as Bt}from"./chunk-VJVXEVZ7.js";import{b as jt,e as Mt,f as Et,i as _t,k as Lt,l as Ut,r as Kt}from"./chunk-MC3ZZA5G.js";import{b as Ot,d as Nt,e as Dt}from"./chunk-5ONH4ITT.js";import{e as Pt,g as Tt,h as Wt,i as _e}from"./chunk-JRAG37V5.js";import{y as St,z as Ir}from"./chunk-2KYGPVTX.js";import{b as $t,f as br}from"./chunk-72SZI2UW.js";import{a as te,b as xt}from"./chunk-A7JSRDJL.js";import{a as At,b as Ee,d as Ce,e as Rt,f as Fe}from"./chunk-BERWTVG2.js";import{c as It,d as vt}from"./chunk-AHWWJ7AF.js";import{fa as Me,qa as kr}from"./chunk-P6WSD2UR.js";import{j as je,r as yr}from"./chunk-UEEB3UTU.js";import{existsSync as vr,mkdirSync as qt,readFileSync as $r,writeFileSync as Sr,renameSync as Ar}from"fs";import{resolve as Jt,dirname as Rr}from"path";var zt=class{filePath;log;constructor(e={}){let t=e.baseDir??Jt(process.cwd(),".agentx");this.filePath=Jt(t,"handover.json"),this.log=e.log??console.error.bind(console,"[handover]"),qt(t,{recursive:!0})}key(e,t,r){return`${e}::${t}::${r||"-"}`}load(){if(!vr(this.filePath))return{version:1,overrides:{}};try{let e=$r(this.filePath,"utf-8"),t=JSON.parse(e);return!t||typeof t!="object"?{version:1,overrides:{}}:(t.overrides||(t.overrides={}),t)}catch(e){return this.log(`load failed, starting empty: ${e?.message||e}`),{version:1,overrides:{}}}}save(e){qt(Rr(this.filePath),{recursive:!0});let t=`${this.filePath}.tmp-${process.pid}`;Sr(t,JSON.stringify(e,null,2)),Ar(t,this.filePath)}get(e,t,r){let s=this.load().overrides[this.key(e,t,r)];if(s&&!(s.expiresAt&&Date.parse(s.expiresAt)<Date.now()))return s}set(e){if(!e.channel||!e.chatId||!e.toAgent)throw new Error("channel, chatId and toAgent are required");let t=this.load(),r={...e,createdAt:e.createdAt??new Date().toISOString()};return t.overrides[this.key(r.channel,r.chatId,r.accountId)]=r,this.save(t),r}remove(e,t,r){let o=this.load(),s=this.key(e,t,r);return s in o.overrides?(delete o.overrides[s],this.save(o),!0):!1}consumeSummary(e,t,r){let o=this.load(),s=o.overrides[this.key(e,t,r)];if(!s||!s.summary||s.summaryConsumedAt)return;let a=s.summary;return s.summaryConsumedAt=new Date().toISOString(),this.save(o),a}listActive(){let e=this.load(),t=Date.now();return Object.values(e.overrides).filter(r=>!r.expiresAt||Date.parse(r.expiresAt)>=t)}listByAgent(e){let t=this.listActive();return{incoming:t.filter(r=>r.toAgent===e),outgoing:t.filter(r=>r.fromAgent===e)}}};import{readFileSync as Zt,writeFileSync as Ue,appendFileSync as Wr,mkdirSync as Or,existsSync as Xt,statSync as Nr}from"fs";import{resolve as fe}from"path";var Yt="[Agent Memory \u2014 persistent facts from past conversations]",xr=2400;function Gt(n,e){return n?`UNVERIFIED (${e===null?"age unknown":`${e}d old`}) `:""}function Pr(n,e=Date.now()){let t=Nt(n,e),r=n.undated?"UNVERIFIED (never checked) ":Gt(t,Pt(n.verifiedAt,e));return{line:`- [wiki ${n.id}] ${r}${n.subject} \xB7 ${n.attribute}: ${n.value} (${n.source}, checked ${n.verifiedAt.slice(0,10)} by ${n.verifiedBy})`,unverified:t}}function Tr(n,e){let r=!n.source.chatId.startsWith("-")&&/^\d+$/.test(n.source.chatId)?"DM":n.source.chatId;if(te(n.content))return{line:`- [${n.category}] ${xt}${n.content} (${r}, ${n.source.date})`,unverified:!0};let o=Wt(n,e);return{line:`- [${n.category}] ${Gt(o,Tt(n,e))}${n.content} (${r}, ${n.source.date})`,unverified:o}}function Vt(n,e=[],t=Date.now()){let r=[],o=new Set,s=Yt.length,a=!1;for(let i of n){let d=e.length>0?Dt(i.content,e):null,l,c,p=d&&Date.parse(i.createdAt)>Date.parse(d.verifiedAt)&&!i.content.toLowerCase().includes(d.value.toLowerCase());if(d&&!p){if(o.has(d.id))continue;o.add(d.id),l=Pr(d,t),c=d.id}else l=Tr(i,t),d&&(l.line+=` [differs from wiki ${d.id}]`);let f=l.unverified&&!a?_e.length:0;if(s+f+l.line.length>xr)break;r.push({fact:i,...l,...c?{wikiRef:c}:{}}),s+=f+l.line.length,f&&(a=!0)}return r}function Qt(n){if(n.length===0)return"";let e=n.some(t=>t.unverified)?[_e]:[];return[Yt,...e,...n.map(t=>t.line),"[End Memory]"].join(`
2
2
  `)}var en=200,Dr=7,tn=class{memoryDir;ledger;constructor(e=process.cwd()){this.memoryDir=fe(e,".agentx/memory"),this.ledger=new Ot(fe(e,".agentx/wiki")),Xt(this.memoryDir)||Or(this.memoryDir,{recursive:!0})}filePath(e){return fe(this.memoryDir,`${e}.jsonl`)}addMemory(e,t){if(t.category==="secret"||Ee(t.content)||te(t.content))return!1;let r=t.source.trust??At(t.source.channel),o=t.review??Rt(r),s={...t,source:{...t.source,trust:r},...o?{review:o}:{},id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,6)}`,createdAt:new Date().toISOString()};return Wr(this.filePath(e),JSON.stringify(s)+`
3
3
  `),!0}parsedCache=new Map;getAll(e){let t=this.filePath(e);if(!Xt(t))return[];try{let{mtimeMs:r,size:o}=Nr(t),s=this.parsedCache.get(t);if(s&&s.mtimeMs===r&&s.size===o)return s.facts.slice();let i=Zt(t,"utf-8").split(`
4
4
  `).filter(d=>d.trim()).map(d=>{try{return JSON.parse(d)}catch{return null}}).filter(d=>d!==null);return this.parsedCache.set(t,{mtimeMs:r,size:o,facts:i}),i.slice()}catch{return[]}}findRelevant(e,t,r=8){let o=this.getAll(t).filter(Fe);if(o.length===0)return[];let s=o.map(g=>`${g.keywords.join(" ")} ${g.content}`),a=fe(this.memoryDir,`${t}_bm25_cache.json`),i=vt(s,a),d=It(e,i),l=new Map(d.map(g=>[g.docIndex,g.score])),p=o.map((g,m)=>{let y=l.get(m)??0;return g.category==="commitment"&&(y+=1),{memory:g,score:y}}).filter(g=>g.score>0);if(p.length===0)return o.slice(-r);let f=p.sort((g,m)=>m.score-g.score).slice(0,r).map(g=>g.memory);if(f.length>0)try{this.recordAccess(t,f.map(g=>g.id))}catch{}return f}buildContext(e){return Qt(this.contextLines(e))}contextFacts(e){return this.contextLines(e).map(t=>t.fact)}contextLines(e){let t=[];try{t=this.ledger.list()}catch{}return Vt(e,t)}recordAccess(e,t){if(t.length===0)return;let r=this.getAll(e),o=new Set(t),s=!1;for(let a of r)if(o.has(a.id)){a.accessCount=(a.accessCount||0)+1,a.lastAccessed=new Date().toISOString();let i=a.intervalDays||1;a.intervalDays=Math.min(i*2,30),a.nextReview=new Date(Date.now()+a.intervalDays*864e5).toISOString(),s=!0}s&&Ue(this.filePath(e),r.map(a=>JSON.stringify(a)).join(`
@@ -39,4 +39,4 @@ ${n.text}`}async function xe(n,e){let t=n.channels[e.channel],r={channel:e.chann
39
39
  `).filter(Boolean),o=[];for(let s=r.length-1;s>=0&&o.length<t;s--)try{let a=JSON.parse(r[s]);(!e||a.person===e)&&o.push(a)}catch{}return o}load(){if(ht(this.file))try{let e=JSON.parse(wt(this.file,"utf-8"));if(e&&Array.isArray(e.devices))return e}catch{}return{devices:[]}}save(e){er(rr(this.file),{recursive:!0});let t=`${this.file}.${process.pid}.${sr(4).toString("hex")}.tmp`;nr(t,JSON.stringify(e,null,2)+`
40
40
  `,{encoding:"utf-8",mode:384}),tr(t,this.file)}};import{extname as si}from"path";var ar=/<agentx-artifact>([\s\S]*?)<\/agentx-artifact>/gi,dr=/<agentx-artifact>[\s\S]*$/i;function _l(n,e=1/0,t=!1){let r=[],o=String(n??"");if(!/<agentx-artifact>/i.test(o))return{text:o,artifacts:r};let s=o.replace(ar,(a,i)=>{try{let d=JSON.parse(i.trim());if(d&&typeof d.filename=="string"&&typeof d.mime=="string"&&r.length<e){let l=d.mime,c=l.startsWith("image/")?"image":l==="application/pdf"?"pdf":l.startsWith("text/")?"text":"file";r.push({type:c,filename:d.filename,mime:l})}}catch{}return""});return{text:(t?s.replace(dr,""):s).trim(),artifacts:r}}function Ll(n,e=!1){let t=String(n??""),r=t;if(/<agentx-artifact>/i.test(t)){let o=t.replace(ar,(s,a)=>{try{let i=JSON.parse(a.trim());return i&&typeof i.filename=="string"?i.filename:""}catch{return""}});r=(e?o.replace(dr,""):o).trim()}return r.replace(/```[\s\S]*?```|`[^`\n]*`|!\[([^\]\n]*)\]\(([^)\s]+)\)/g,(o,s,a)=>s===void 0||a===void 0?o:`[${s||a}](${a})`)}var ii={".png":{mime:"image/png",kind:"image"},".jpg":{mime:"image/jpeg",kind:"image"},".jpeg":{mime:"image/jpeg",kind:"image"},".gif":{mime:"image/gif",kind:"image"},".webp":{mime:"image/webp",kind:"image"},".svg":{mime:"image/svg+xml",kind:"file"},".pdf":{mime:"application/pdf",kind:"file"},".txt":{mime:"text/plain; charset=utf-8",kind:"file"},".md":{mime:"text/markdown; charset=utf-8",kind:"file"},".csv":{mime:"text/csv; charset=utf-8",kind:"file"},".json":{mime:"application/json",kind:"file"},".mp3":{mime:"audio/mpeg",kind:"audio"},".m4a":{mime:"audio/mp4",kind:"audio"},".wav":{mime:"audio/wav",kind:"audio"},".mp4":{mime:"video/mp4",kind:"video"},".webm":{mime:"video/webm",kind:"video"}},Ul={bytes:20*1024*1024,perMessage:20,pathChars:512};function Hl(n){return ii[si(n).toLowerCase()]??null}var ai=["[Phone app: showing files]","To show the owner a file you created (a chart, a screenshot, a PDF, a recording), save or copy it into .agentx/outbox/ in your workspace and end your reply with one line per file:",'<agentx-artifact>{"filename":".agentx/outbox/<name.ext>","mime":"<mime/type>"}</agentx-artifact>',"Files outside your workspace (/tmp, your home folder) are refused. Outbox files are removed after 7 days.","The line is removed from the text. Images show in the reply, audio and video get a player, other files an Open link. Allowed: png, jpg, gif, webp, svg, pdf, txt, md, csv, json, mp3, m4a, wav, mp4, webm; up to 20 MB and 20 files per reply.","A picture already on the web can go inline as ![what it shows](https://...)."].join(`
41
41
  `);function Bl(n,e,t){return n==="app"&&e&&t!==!1?ai:void 0}import{lstatSync as kt,mkdirSync as di,readdirSync as li,realpathSync as yt,unlinkSync as ui}from"fs";import{join as Ne,resolve as lr}from"path";var ur=".agentx/outbox",ci=7*24*60*60*1e3;function pi(n,e){try{let t=yt(lr(e,n)),r=Ne(t,ur);return yt(r)===r&&kt(r).isDirectory()?r:null}catch{return null}}function zl(n,e={}){let t=e.cwd??process.cwd();if(e.create!==!1)try{let o=yt(lr(t,n));kt(Ne(o,".agentx"),{throwIfNoEntry:!1})?.isSymbolicLink()||di(Ne(o,ur),{recursive:!0})}catch{return 0}let r=pi(n,t);return r?cr(r,(e.now??Date.now())-(e.maxAgeMs??ci)):0}function cr(n,e){let t=0;for(let r of li(n)){let o=Ne(n,r);try{let s=kt(o);s.isDirectory()?t+=cr(o,e):Math.max(s.mtimeMs,s.ctimeMs)<e&&(ui(o),t++)}catch{}}return t}export{zt as a,tn as b,nn as c,Wi as d,Er as e,Oi as f,Fr as g,ji as h,Mi as i,Ei as j,Ci as k,Fi as l,_i as m,Li as n,Ur as o,Ui as p,Hi as q,Ji as r,qe as s,Gr as t,zi as u,Yi as v,Vr as w,Gi as x,un as y,Zi as z,Xi as A,pn as B,fn as C,to as D,oa as E,sa as F,da as G,la as H,x as I,ne as J,S as K,ze as L,yo as M,Ve as N,L as O,Xe as P,tt as Q,pt as R,As as S,Os as T,gt as U,Eo as V,qs as W,al as X,dl as Y,ll as Z,ul as _,cl as $,Js as aa,zs as ba,pl as ca,fl as da,gl as ea,ml as fa,yl as ga,kl as ha,bl as ia,Il as ja,vl as ka,$l as la,Sl as ma,Al as na,Rl as oa,xl as pa,Pl as qa,Xs as ra,Tl as sa,Wl as ta,Ol as ua,Nl as va,ir as wa,_l as xa,Ll as ya,Ul as za,Hl as Aa,Bl as Ba,ur as Ca,zl as Da};
42
- //# sourceMappingURL=chunk-VK2TW3RL.js.map
42
+ //# sourceMappingURL=chunk-PO2SORKY.js.map
@@ -1,4 +1,4 @@
1
- import{Hb as m,yb as l}from"./chunk-6ZAQ3IT5.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
1
+ import{Ib as m,zb as l}from"./chunk-P6WSD2UR.js";m();import{existsSync as g,readFileSync as u,writeFileSync as a,copyFileSync as y}from"fs";import{resolve as p}from"path";function P(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(!g(t))throw new Error(`agentx.json not found at ${t}`);let i=JSON.parse(u(t,"utf-8")),o=e(i),s=typeof o=="string"?{summary:o}:o,c=JSON.stringify(i,null,2)+`
2
2
  `,f=t+".tmp";a(f,c,"utf-8");try{JSON.parse(u(f,"utf-8"))}catch(d){throw new Error(`config did not round-trip cleanly: ${d.message}`)}let r;return n.skipBackup||(r=`${t}.bak.${Date.now()}`,y(t,r)),a(t,c,"utf-8"),n.skipReload||h().catch(()=>{}),{summary:s.summary,payload:s.payload,backupPath:r}}function S(e,n={}){let t=n.configPath||p(process.cwd(),"agentx.json");if(g(t)&&!n.overwrite)throw new Error(`agentx.json already exists at ${t}. Pass overwrite=true to replace it.`);return a(t,JSON.stringify(e,null,2)+`
3
3
  `,"utf-8"),{file:t}}async function h(){try{let n=l().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${n}/reload`,{method:"POST"}).catch(()=>null)}catch{}}export{P as a,S as b};
4
- //# sourceMappingURL=chunk-N56EHPTR.js.map
4
+ //# sourceMappingURL=chunk-PX7PWXBI.js.map
@@ -1,4 +1,4 @@
1
- import{a as h}from"./chunk-MQV3IU6F.js";import{resolve as n}from"path";import{existsSync as c,readdirSync as u,mkdirSync as l,readFileSync as p,writeFileSync as f,renameSync as S}from"fs";var m=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=n(process.cwd(),".agentx/wiki"),r=console.error.bind(console,"[wiki-hub]"),t="graph"){this.baseDir=e,this.agentsDir=n(e,"agents"),this.mode=t,this.log=r,l(this.agentsDir,{recursive:!0}),this.sharedStore=new h(e,r)}getMode(){return this.mode}getAgentWiki(e){let r=`${e}:${this.mode}`;if(this.agentStores.has(r))return this.agentStores.get(r);let t=n(this.agentsDir,e,this.mode),s=new h(t,this.log);return this.agentStores.set(r,s),s}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}sharedScope(e){return[...this.listAgentDirs().filter(t=>t!==e).map(t=>({id:t,store:this.getAgentWiki(t)})),{id:"shared",store:this.sharedStore,skip:t=>t.startsWith("agents/")}]}listAgentDirs(){return c(this.agentsDir)?u(this.agentsDir).filter(e=>!e.startsWith("_")&&!e.startsWith(".")&&c(n(this.agentsDir,e,this.mode))).sort():[]}listAgents(e=this.sharedStore.listEntries()){let r=new Set;for(let t of e)r.add(t.agentId);if(c(this.agentsDir))for(let t of u(this.agentsDir))!t.startsWith("_")&&!t.startsWith(".")&&r.add(t);return[...r].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){return this.classifyEntries(e).pending}markProcessed(e,r,t){let s=new Set(t),g=this.readLedger(e),d=new Date().toISOString();for(let i of r)g.entries[i]={at:d,cited:s.has(i)};let o=this.ledgerPath(e);l(n(o,".."),{recursive:!0});let a=`${o}.tmp`;f(a,`${JSON.stringify(g,null,2)}
1
+ import{a as h}from"./chunk-ZALVAXQ4.js";import{resolve as n}from"path";import{existsSync as c,readdirSync as u,mkdirSync as l,readFileSync as p,writeFileSync as f,renameSync as S}from"fs";var m=class{baseDir;agentsDir;mode;sharedStore;agentStores=new Map;log;constructor(e=n(process.cwd(),".agentx/wiki"),r=console.error.bind(console,"[wiki-hub]"),t="graph"){this.baseDir=e,this.agentsDir=n(e,"agents"),this.mode=t,this.log=r,l(this.agentsDir,{recursive:!0}),this.sharedStore=new h(e,r)}getMode(){return this.mode}getAgentWiki(e){let r=`${e}:${this.mode}`;if(this.agentStores.has(r))return this.agentStores.get(r);let t=n(this.agentsDir,e,this.mode),s=new h(t,this.log);return this.agentStores.set(r,s),s}getBaseDir(){return this.baseDir}getSharedStore(){return this.sharedStore}sharedScope(e){return[...this.listAgentDirs().filter(t=>t!==e).map(t=>({id:t,store:this.getAgentWiki(t)})),{id:"shared",store:this.sharedStore,skip:t=>t.startsWith("agents/")}]}listAgentDirs(){return c(this.agentsDir)?u(this.agentsDir).filter(e=>!e.startsWith("_")&&!e.startsWith(".")&&c(n(this.agentsDir,e,this.mode))).sort():[]}listAgents(e=this.sharedStore.listEntries()){let r=new Set;for(let t of e)r.add(t.agentId);if(c(this.agentsDir))for(let t of u(this.agentsDir))!t.startsWith("_")&&!t.startsWith(".")&&r.add(t);return[...r].sort()}getAgentEntries(e){return this.sharedStore.listEntries({agentId:e})}getUnabsorbedEntries(e){return this.classifyEntries(e).pending}markProcessed(e,r,t){let s=new Set(t),g=this.readLedger(e),d=new Date().toISOString();for(let i of r)g.entries[i]={at:d,cited:s.has(i)};let o=this.ledgerPath(e);l(n(o,".."),{recursive:!0});let a=`${o}.tmp`;f(a,`${JSON.stringify(g,null,2)}
2
2
  `),S(a,o)}summary(){let e=this.sharedStore.listEntries(),r=new Map;for(let t of e){let s=r.get(t.agentId);s?s.push(t):r.set(t.agentId,[t])}return this.listAgents(e).map(t=>{let{all:s,cited:g,read:d,pending:o,articles:a}=this.classifyEntries(t,r.get(t)??[]);return{agentId:t,totalEntries:s.length,totalArticles:a.length,cited:g.length,readNotCited:d.length,unabsorbed:o.length,articles:a}})}classifyEntries(e,r=this.getAgentEntries(e)){let t=this.getAgentWiki(e).rebuildIndex().articles,s=new Set;for(let i of t)if(i.sources)for(let y of i.sources)s.add(y);let g=this.readLedger(e).entries,d=[],o=[],a=[];for(let i of r)s.has(i.id)?d.push(i):g[i.id]?o.push(i):a.push(i);return{all:r,cited:d,read:o,pending:a,articles:t}}syncedFrom(e){let r=n(this.agentsDir,e,"_synced.json");if(!c(r))return null;try{return JSON.parse(p(r,"utf-8"))}catch(t){return this.log(`synced marker ${r} is not valid JSON: ${t.message}`),{node:"unknown",peerUrl:"",at:""}}}markSynced(e,r){let t=n(this.agentsDir,e,"_synced.json");l(n(t,".."),{recursive:!0});let s=`${t}.tmp`;f(s,`${JSON.stringify(r,null,2)}
3
3
  `),S(s,t)}ledgerPath(e){return n(this.agentsDir,e,"_absorbed.json")}readLedger(e){let r=this.ledgerPath(e);if(!c(r))return{entries:{}};try{return{entries:JSON.parse(p(r,"utf-8")).entries??{}}}catch(t){throw new Error(`absorb ledger ${r} is not valid JSON: ${t.message}`)}}};export{m as a};
4
- //# sourceMappingURL=chunk-EI3TZ52P.js.map
4
+ //# sourceMappingURL=chunk-RW5FKJRE.js.map