agentix-cli 0.78.0 → 0.79.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 (111) hide show
  1. package/dist/{App-UNWLWLH5.js → App-NZQQXETO.js} +2 -2
  2. package/dist/{ChatApp-UBSOVFRK.js → ChatApp-CSVN3PRK.js} +2 -2
  3. package/dist/{agent-XWWWL5RV.js → agent-RTZDVG5B.js} +2 -2
  4. package/dist/{board-dashboard-ABEIELBC.js → board-dashboard-SI5GP3XR.js} +4 -4
  5. package/dist/{board-dashboard-ABEIELBC.js.map → board-dashboard-SI5GP3XR.js.map} +1 -1
  6. package/dist/{chunk-H4RCKWJA.js → chunk-2WRWBPDL.js} +2 -2
  7. package/dist/{chunk-SLQZ4AHG.js → chunk-2XSVV3M3.js} +2 -2
  8. package/dist/chunk-2YIWQ57T.js +22 -0
  9. package/dist/chunk-2YIWQ57T.js.map +1 -0
  10. package/dist/{chunk-U6XM4M5V.js → chunk-3AFZBXNX.js} +2 -2
  11. package/dist/{chunk-JVJYCR67.js → chunk-3OIFSKSR.js} +2 -2
  12. package/dist/{chunk-FWDWHZ6H.js → chunk-B5VRY4NI.js} +2 -2
  13. package/dist/{chunk-4EJ65BMF.js → chunk-DTKTEQPC.js} +194 -194
  14. package/dist/chunk-DTKTEQPC.js.map +1 -0
  15. package/dist/{chunk-2XICJMS6.js → chunk-EOBFJGTV.js} +30 -30
  16. package/dist/chunk-EOBFJGTV.js.map +1 -0
  17. package/dist/{chunk-4STRKIUA.js → chunk-IWQURDYO.js} +2 -2
  18. package/dist/{chunk-WEUF5WRR.js → chunk-IXWPA6WM.js} +2 -2
  19. package/dist/chunk-KH4PKJGD.js +15 -0
  20. package/dist/chunk-KH4PKJGD.js.map +1 -0
  21. package/dist/{chunk-53J2D2ZJ.js → chunk-N2A3KIVY.js} +2 -2
  22. package/dist/{chunk-NWP44FEW.js → chunk-P5KHF46N.js} +2 -2
  23. package/dist/{chunk-GTZDTKDW.js → chunk-PF5ZXMEG.js} +2 -2
  24. package/dist/{chunk-TVORP6BW.js → chunk-QAKL2D7O.js} +2 -2
  25. package/dist/{chunk-GX4U2ILS.js → chunk-QIMIARFO.js} +2 -2
  26. package/dist/{chunk-R7AS5M32.js → chunk-SYXAEWFN.js} +5 -5
  27. package/dist/{chunk-IMVW5ZSY.js → chunk-THZOPGSP.js} +2 -2
  28. package/dist/{chunk-KEPK7ZZ2.js → chunk-TQT4XDNN.js} +2 -2
  29. package/dist/{chunk-JQXP3JWF.js → chunk-VIUCCUJ4.js} +2 -2
  30. package/dist/{chunk-FSVUSXJB.js → chunk-YX5S4FHR.js} +17 -17
  31. package/dist/{chunk-FSVUSXJB.js.map → chunk-YX5S4FHR.js.map} +1 -1
  32. package/dist/{chunk-6HUDHMAC.js → chunk-ZBRZ5T2G.js} +2 -2
  33. package/dist/cli.js +1 -1
  34. package/dist/client-TZPRACLX.js +2 -0
  35. package/dist/{config-44LINWKG.js → config-OQVGSZWB.js} +2 -2
  36. package/dist/config-mutator-BA7YVYJY.js +2 -0
  37. package/dist/{doctor-OXR3VXX6.js → doctor-NHEB7IMW.js} +2 -2
  38. package/dist/{editor-chat-V24MXQIB.js → editor-chat-4MLCP5D2.js} +5 -3
  39. package/dist/editor-chat-4MLCP5D2.js.map +1 -0
  40. package/dist/index.d.ts +13 -3
  41. package/dist/index.js +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/program-N3AVBQMK.js +2 -0
  44. package/dist/{promote-72BY34SI.js → promote-O6Y2RG4K.js} +2 -2
  45. package/dist/{query-AJO3NOO6.js → query-J3XX5U3P.js} +2 -2
  46. package/dist/registry-DBLLSQ75.js +2 -0
  47. package/dist/{request-planner-Q74NYFRJ.js → request-planner-NP2XHSMV.js} +2 -2
  48. package/dist/{review-candidates-ZBBIPFJT.js → review-candidates-J3OBF4GM.js} +2 -2
  49. package/dist/{routing-7VU524EZ.js → routing-VTQBG767.js} +2 -2
  50. package/dist/schedule-tool-RQBVG3ZJ.js +2 -0
  51. package/dist/scheduler-BHXA74R6.js +2 -0
  52. package/dist/{seat-MKY332GD.js → seat-NBQOUDGU.js} +2 -2
  53. package/dist/{select-FZX63JK5.js → select-T5FEWTZA.js} +2 -2
  54. package/dist/{set-enabled-RNDSUIYU.js → set-enabled-2GHZXDEA.js} +2 -2
  55. package/dist/{tool-XBSFEGWW.js → tool-6WLJTCE5.js} +2 -2
  56. package/dist/web/workflow-editor.global.js +10 -10
  57. package/dist/web/workflow-editor.global.js.map +1 -1
  58. package/dist/wiki-ZB6KMJKX.js +2 -0
  59. package/package.json +1 -1
  60. package/dist/chunk-2XICJMS6.js.map +0 -1
  61. package/dist/chunk-4EJ65BMF.js.map +0 -1
  62. package/dist/chunk-DBXN7I2X.js +0 -15
  63. package/dist/chunk-DBXN7I2X.js.map +0 -1
  64. package/dist/chunk-LQJNRSCT.js +0 -21
  65. package/dist/chunk-LQJNRSCT.js.map +0 -1
  66. package/dist/client-OAAE3KM5.js +0 -2
  67. package/dist/config-mutator-P6QEABPU.js +0 -2
  68. package/dist/editor-chat-V24MXQIB.js.map +0 -1
  69. package/dist/program-X7ROPRQP.js +0 -2
  70. package/dist/registry-AFNYREN2.js +0 -2
  71. package/dist/schedule-tool-6RRXRW5K.js +0 -2
  72. package/dist/scheduler-WA4KTCCU.js +0 -2
  73. package/dist/wiki-ZOK6XGIX.js +0 -2
  74. /package/dist/{App-UNWLWLH5.js.map → App-NZQQXETO.js.map} +0 -0
  75. /package/dist/{ChatApp-UBSOVFRK.js.map → ChatApp-CSVN3PRK.js.map} +0 -0
  76. /package/dist/{agent-XWWWL5RV.js.map → agent-RTZDVG5B.js.map} +0 -0
  77. /package/dist/{chunk-H4RCKWJA.js.map → chunk-2WRWBPDL.js.map} +0 -0
  78. /package/dist/{chunk-SLQZ4AHG.js.map → chunk-2XSVV3M3.js.map} +0 -0
  79. /package/dist/{chunk-U6XM4M5V.js.map → chunk-3AFZBXNX.js.map} +0 -0
  80. /package/dist/{chunk-JVJYCR67.js.map → chunk-3OIFSKSR.js.map} +0 -0
  81. /package/dist/{chunk-FWDWHZ6H.js.map → chunk-B5VRY4NI.js.map} +0 -0
  82. /package/dist/{chunk-4STRKIUA.js.map → chunk-IWQURDYO.js.map} +0 -0
  83. /package/dist/{chunk-WEUF5WRR.js.map → chunk-IXWPA6WM.js.map} +0 -0
  84. /package/dist/{chunk-53J2D2ZJ.js.map → chunk-N2A3KIVY.js.map} +0 -0
  85. /package/dist/{chunk-NWP44FEW.js.map → chunk-P5KHF46N.js.map} +0 -0
  86. /package/dist/{chunk-GTZDTKDW.js.map → chunk-PF5ZXMEG.js.map} +0 -0
  87. /package/dist/{chunk-TVORP6BW.js.map → chunk-QAKL2D7O.js.map} +0 -0
  88. /package/dist/{chunk-GX4U2ILS.js.map → chunk-QIMIARFO.js.map} +0 -0
  89. /package/dist/{chunk-R7AS5M32.js.map → chunk-SYXAEWFN.js.map} +0 -0
  90. /package/dist/{chunk-IMVW5ZSY.js.map → chunk-THZOPGSP.js.map} +0 -0
  91. /package/dist/{chunk-KEPK7ZZ2.js.map → chunk-TQT4XDNN.js.map} +0 -0
  92. /package/dist/{chunk-JQXP3JWF.js.map → chunk-VIUCCUJ4.js.map} +0 -0
  93. /package/dist/{chunk-6HUDHMAC.js.map → chunk-ZBRZ5T2G.js.map} +0 -0
  94. /package/dist/{client-OAAE3KM5.js.map → client-TZPRACLX.js.map} +0 -0
  95. /package/dist/{config-44LINWKG.js.map → config-OQVGSZWB.js.map} +0 -0
  96. /package/dist/{config-mutator-P6QEABPU.js.map → config-mutator-BA7YVYJY.js.map} +0 -0
  97. /package/dist/{doctor-OXR3VXX6.js.map → doctor-NHEB7IMW.js.map} +0 -0
  98. /package/dist/{program-X7ROPRQP.js.map → program-N3AVBQMK.js.map} +0 -0
  99. /package/dist/{promote-72BY34SI.js.map → promote-O6Y2RG4K.js.map} +0 -0
  100. /package/dist/{query-AJO3NOO6.js.map → query-J3XX5U3P.js.map} +0 -0
  101. /package/dist/{registry-AFNYREN2.js.map → registry-DBLLSQ75.js.map} +0 -0
  102. /package/dist/{request-planner-Q74NYFRJ.js.map → request-planner-NP2XHSMV.js.map} +0 -0
  103. /package/dist/{review-candidates-ZBBIPFJT.js.map → review-candidates-J3OBF4GM.js.map} +0 -0
  104. /package/dist/{routing-7VU524EZ.js.map → routing-VTQBG767.js.map} +0 -0
  105. /package/dist/{schedule-tool-6RRXRW5K.js.map → schedule-tool-RQBVG3ZJ.js.map} +0 -0
  106. /package/dist/{scheduler-WA4KTCCU.js.map → scheduler-BHXA74R6.js.map} +0 -0
  107. /package/dist/{seat-MKY332GD.js.map → seat-NBQOUDGU.js.map} +0 -0
  108. /package/dist/{select-FZX63JK5.js.map → select-T5FEWTZA.js.map} +0 -0
  109. /package/dist/{set-enabled-RNDSUIYU.js.map → set-enabled-2GHZXDEA.js.map} +0 -0
  110. /package/dist/{tool-XBSFEGWW.js.map → tool-6WLJTCE5.js.map} +0 -0
  111. /package/dist/{wiki-ZOK6XGIX.js.map → wiki-ZB6KMJKX.js.map} +0 -0
@@ -1,4 +1,4 @@
1
- import{a as j,b as O,c as T,d as D,e as _,j as N}from"./chunk-JQXP3JWF.js";import{b as R}from"./chunk-2GIDVZ4H.js";import{v as C,w as I}from"./chunk-TVORP6BW.js";import{b as v,c as W}from"./chunk-QOYAX2FT.js";import{readFileSync as Y,existsSync as B}from"fs";I();import{resolve as x}from"path";import{execSync as L}from"child_process";async function nt(n,a,o,t={}){let u=t.selectorModel??"haiku",g=t.synthModel??"sonnet",l=t.maxCandidates??3,r=t.maxHops??2,s=t.maxArticles??8,h=t.timeoutMs??6e4,p=t.log??console.error.bind(console,"[wiki-query]"),m=t.messagePath?.length?t.messagePath:void 0,w=t.graphWeight??$,i=x(a.baseDir,"_index.md");if(!B(i))return A("no-catalog",n,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let e=Y(i,"utf-8"),d=Date.now(),f=[],y="";try{let c=await G(n,a,o,l,m,w);c?(f=c,y=`[wiki-rerank seat] ${c.map(k=>k.title).join(" | ")}`):(y=await Q(q(n,e,l,m),u,h),f=K(y))}catch(c){return p("selector failed:",c?.message),{...A("error",n,`Selector: ${c?.message||"unknown"}`),trace:{selectorMs:Date.now()-d,synthesisMs:0,selectorOutput:y}}}let S=Date.now()-d;if(f.length===0)return{...A("no-candidates",n,"Selector returned no candidates."),trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let b=F(f,a,o,r,s);if(b.length===0)return{...A("no-candidates",n,"Candidates did not resolve to readable articles."),candidates:f,trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let M=Date.now(),P="";try{P=await Q(J(n,b),g,h*2)}catch(c){return p("synthesis failed:",c?.message),{...A("error",n,`Synthesis: ${c?.message||"unknown"}`),candidates:f,walked:b.map(k=>({title:k.meta.title,path:k.path,type:k.meta.type,hop:k.hop??0})),trace:{selectorMs:S,synthesisMs:Date.now()-M,selectorOutput:y}}}let E=Date.now()-M;return{answer:P.trim(),citations:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type})),candidates:f,walked:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type,hop:c.hop??0})),status:"ok",trace:{selectorMs:S,synthesisMs:E,selectorOutput:y}}}function A(n,a,o){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:o}}function F(n,a,o,t,u){let g=new Map;for(let s of a.listArticles(o||""))g.set(s.meta.title.toLowerCase(),s.path);let l=new Map,r=[];for(let s of n)l.has(s.path)||r.push({path:s.path,hop:0});for(;r.length&&l.size<u;){let s=r.shift();if(l.has(s.path)||s.hop>t)continue;let h=o?a.readArticleAs(s.path,o):a.readArticle(s.path);if(h&&(l.set(s.path,{...h,hop:s.hop}),!(s.hop>=t)))for(let p of h.meta.related||[]){let m=g.get(p.toLowerCase());m&&!l.has(m)&&r.push({path:m,hop:s.hop+1})}}return Array.from(l.values())}async function G(n,a,o,t,u,g=$){try{let r=(a.rebuildIndex().articles??[]).filter(i=>i.path&&!i.path.includes("/_versions/"));if(r.length<2)return null;let h=H(n,r,u,g).slice(0,O).map(i=>({id:`k${i}`,title:r[i].title||r[i].path,tags:r[i].tags,excerpt:[r[i].type?`type: ${r[i].type}`:"",(r[i].related??[]).length?`related: ${(r[i].related??[]).join(", ")}`:"",(r[i].graphPath??[]).length?`graph: ${(r[i].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),p=await C(j,T({query:n,candidates:h,excerptChars:300}),D(h),{features:{agent:o??"unknown",stage:"catalog-selector"}});if(!p||p.mode!=="active")return null;let w=_(p.answers,h).ranked.slice(0,t).map(i=>r[Number(i.slice(1))]).filter(Boolean).map(i=>({title:i.title,path:i.path}));return w.length>0?w:null}catch{return null}}var $=.6;function H(n,a,o,t=$){let u=a.map(e=>[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")),g=W(n,v(u)),l=g.reduce((e,d)=>Math.max(e,d.score),0),r=new Map(g.map(e=>[e.docIndex,l>0?e.score/l:0])),s=!!o?.length,h=e=>s&&e.graphPath?.length?N(o,e.graphPath):0,p=(e,d)=>d.score-e.score||e.i-d.i,m=a.map((e,d)=>({i:d,score:(r.get(d)??0)*(1+t*h(e))})).filter(e=>r.has(e.i)).sort(p),w=a.map((e,d)=>({i:d,score:h(e)})).filter(e=>!r.has(e.i)&&e.score>0).sort(p),i=[...m,...w].map(e=>e.i);for(let e=0;e<a.length;e++)i.includes(e)||i.push(e);return i}function q(n,a,o,t){let u=t?.length?`
1
+ import{a as j,b as O,c as T,d as D,e as _,j as N}from"./chunk-VIUCCUJ4.js";import{b as R}from"./chunk-2GIDVZ4H.js";import{v as C,w as I}from"./chunk-QAKL2D7O.js";import{b as v,c as W}from"./chunk-QOYAX2FT.js";import{readFileSync as Y,existsSync as B}from"fs";I();import{resolve as x}from"path";import{execSync as L}from"child_process";async function nt(n,a,o,t={}){let u=t.selectorModel??"haiku",g=t.synthModel??"sonnet",l=t.maxCandidates??3,r=t.maxHops??2,s=t.maxArticles??8,h=t.timeoutMs??6e4,p=t.log??console.error.bind(console,"[wiki-query]"),m=t.messagePath?.length?t.messagePath:void 0,w=t.graphWeight??$,i=x(a.baseDir,"_index.md");if(!B(i))return A("no-catalog",n,"No _index.md found \u2014 run `agentx wiki status` to rebuild.");let e=Y(i,"utf-8"),d=Date.now(),f=[],y="";try{let c=await G(n,a,o,l,m,w);c?(f=c,y=`[wiki-rerank seat] ${c.map(k=>k.title).join(" | ")}`):(y=await Q(q(n,e,l,m),u,h),f=K(y))}catch(c){return p("selector failed:",c?.message),{...A("error",n,`Selector: ${c?.message||"unknown"}`),trace:{selectorMs:Date.now()-d,synthesisMs:0,selectorOutput:y}}}let S=Date.now()-d;if(f.length===0)return{...A("no-candidates",n,"Selector returned no candidates."),trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let b=F(f,a,o,r,s);if(b.length===0)return{...A("no-candidates",n,"Candidates did not resolve to readable articles."),candidates:f,trace:{selectorMs:S,synthesisMs:0,selectorOutput:y}};let M=Date.now(),P="";try{P=await Q(J(n,b),g,h*2)}catch(c){return p("synthesis failed:",c?.message),{...A("error",n,`Synthesis: ${c?.message||"unknown"}`),candidates:f,walked:b.map(k=>({title:k.meta.title,path:k.path,type:k.meta.type,hop:k.hop??0})),trace:{selectorMs:S,synthesisMs:Date.now()-M,selectorOutput:y}}}let E=Date.now()-M;return{answer:P.trim(),citations:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type})),candidates:f,walked:b.map(c=>({title:c.meta.title,path:c.path,type:c.meta.type,hop:c.hop??0})),status:"ok",trace:{selectorMs:S,synthesisMs:E,selectorOutput:y}}}function A(n,a,o){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:o}}function F(n,a,o,t,u){let g=new Map;for(let s of a.listArticles(o||""))g.set(s.meta.title.toLowerCase(),s.path);let l=new Map,r=[];for(let s of n)l.has(s.path)||r.push({path:s.path,hop:0});for(;r.length&&l.size<u;){let s=r.shift();if(l.has(s.path)||s.hop>t)continue;let h=o?a.readArticleAs(s.path,o):a.readArticle(s.path);if(h&&(l.set(s.path,{...h,hop:s.hop}),!(s.hop>=t)))for(let p of h.meta.related||[]){let m=g.get(p.toLowerCase());m&&!l.has(m)&&r.push({path:m,hop:s.hop+1})}}return Array.from(l.values())}async function G(n,a,o,t,u,g=$){try{let r=(a.rebuildIndex().articles??[]).filter(i=>i.path&&!i.path.includes("/_versions/"));if(r.length<2)return null;let h=H(n,r,u,g).slice(0,O).map(i=>({id:`k${i}`,title:r[i].title||r[i].path,tags:r[i].tags,excerpt:[r[i].type?`type: ${r[i].type}`:"",(r[i].related??[]).length?`related: ${(r[i].related??[]).join(", ")}`:"",(r[i].graphPath??[]).length?`graph: ${(r[i].graphPath??[]).join(" \u203A ")}`:""].filter(Boolean).join(" \xB7 ")})),p=await C(j,T({query:n,candidates:h,excerptChars:300}),D(h),{features:{agent:o??"unknown",stage:"catalog-selector"}});if(!p||p.mode!=="active")return null;let w=_(p.answers,h).ranked.slice(0,t).map(i=>r[Number(i.slice(1))]).filter(Boolean).map(i=>({title:i.title,path:i.path}));return w.length>0?w:null}catch{return null}}var $=.6;function H(n,a,o,t=$){let u=a.map(e=>[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")),g=W(n,v(u)),l=g.reduce((e,d)=>Math.max(e,d.score),0),r=new Map(g.map(e=>[e.docIndex,l>0?e.score/l:0])),s=!!o?.length,h=e=>s&&e.graphPath?.length?N(o,e.graphPath):0,p=(e,d)=>d.score-e.score||e.i-d.i,m=a.map((e,d)=>({i:d,score:(r.get(d)??0)*(1+t*h(e))})).filter(e=>r.has(e.i)).sort(p),w=a.map((e,d)=>({i:d,score:h(e)})).filter(e=>!r.has(e.i)&&e.score>0).sort(p),i=[...m,...w].map(e=>e.i);for(let e=0;e<a.length;e++)i.includes(e)||i.push(e);return i}function q(n,a,o,t){let u=t?.length?`
2
2
  ## Intent
3
3
 
4
4
  The request was classified under the intent-graph path "${t.join(" \u203A ")}". Prefer articles filed under the same branch when their titles are equally plausible.
@@ -46,4 +46,4 @@ ${o}
46
46
  Answer the question in 2\u20136 sentences. Cite articles by their title in square brackets like [Article Title]. If the articles do not answer the question, say so plainly (do not invent). Prefer concrete facts over hedging.
47
47
 
48
48
  Output ONLY the answer \u2014 no preamble, no "here is my answer:", no markdown fencing.`}function K(n){let a=n.match(/\[[\s\S]*?\]/);if(!a)return[];try{let o=JSON.parse(a[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 Q(n,a,o){let{writeFileSync:t,mkdirSync:u,rmSync:g}=await import("fs"),{tmpdir:l}=await import("os"),r=x(l(),`agentx-wiki-query-${process.pid}`);u(r,{recursive:!0});let s=x(r,`prompt-${Date.now()}.txt`);t(s,n);try{let h=`cat '${s}' | claude -p - --output-format json --max-turns 1 --model ${a} --disallowedTools "Bash Read Write Edit Glob Grep Agent WebSearch WebFetch NotebookEdit"`,p=L(h,{env:R({...process.env}),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let m=JSON.parse(p);return String(m.result||m.content||"")}catch{return p}}finally{try{g(s,{force:!0})}catch{}}}export{nt as a,$ as b,H as c};
49
- //# sourceMappingURL=chunk-U6XM4M5V.js.map
49
+ //# sourceMappingURL=chunk-3AFZBXNX.js.map
@@ -1,4 +1,4 @@
1
- import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-DP7RTNDM.js";import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{a as E}from"./chunk-GTZDTKDW.js";import{b as L}from"./chunk-CECHWYJ2.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c=""){return Z(r,s,t,o,i,c)}function Z(n,r,s,t,o,i=""){let c=r?`
1
+ import{b as Y,c as I,d as O}from"./chunk-AQASR6KR.js";import{b as F}from"./chunk-DP7RTNDM.js";import{q as _,r as W}from"./chunk-2AXFYDWF.js";import{a as E}from"./chunk-PF5ZXMEG.js";import{b as L}from"./chunk-CECHWYJ2.js";import{createHash as ee}from"crypto";import{existsSync as H,readdirSync as te,readFileSync as re,writeFileSync as ne}from"fs";import{resolve as P}from"path";function be(n,r,s,t,o,i,c=""){return Z(r,s,t,o,i,c)}function Z(n,r,s,t,o,i=""){let c=r?`
2
2
  ## Worldview
3
3
 
4
4
  ${r}
@@ -240,4 +240,4 @@ ${g}`}var x="memory-promoter",oe=["project","reference","feedback"],K="_memory-p
240
240
  Re-emit the FULL corrected JSON object \u2014 same structure, fixed issues, valid JSON only.`:n,y=await t(`${a}/task`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({agent:r.viaAgent,message:h,freshSession:s===null,context:{channel:"api",chatId:r.chatId??"memory-promote"}}),signal:i.signal});if(!y.ok){let f=await y.text().catch(()=>"");throw new Error(`agent /task ${y.status}: ${f.slice(0,500)}`)}let w=await y.json();if(w.error)throw new Error(`agent reported error: ${w.error}`);let b=String(w.content??"").trim();if(!b)throw new Error("agent returned empty content");return b}if(!r.model)throw new Error("callPromotionLlm: viaAgent or model is required");let p=process.env.ANTHROPIC_API_KEY;if(!p)throw new Error("ANTHROPIC_API_KEY not set; use --via <agentId> instead");let u=[{role:"user",content:n}];s&&(u.push({role:"assistant",content:"(previous attempt; will retry with corrections)"}),u.push({role:"user",content:`Your previous response failed validation: ${s}
241
241
  Re-emit the FULL corrected JSON object.`}));let g=await t(me,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":p,"anthropic-version":ge},body:JSON.stringify({model:r.model,max_tokens:8e3,messages:u}),signal:i.signal});if(!g.ok){let a=await g.text().catch(()=>"");throw new Error(`anthropic API ${g.status}: ${a.slice(0,500)}`)}let l=await g.json(),e=(Array.isArray(l.content)?l.content:[]).filter(a=>a?.type==="text").map(a=>a.text).join(`
242
242
  `).trim();if(!e)throw new Error("anthropic API returned no text content");return e}finally{clearTimeout(c)}}async function Se(n={}){let r=n.wikiDir??P(process.cwd(),".agentx","wiki"),s=n.memoryRoot??P(process.cwd(),".agentx"),t=n.log??(()=>{}),o=n.now??Date.now(),i={candidates:[],clusters:[],proposed:[],skipped:[],gaps:[],warnings:[],errors:[],dryRun:!n.commit},c=new E(r,(...m)=>t(m.map(String).join(" "))),p=c.rebuildIndex(),u=z(r),g=[...ce(s),...n.extraCandidates??[]];if(i.candidates=de(g,p,u,{types:n.types,sinceMs:n.sinceMs,agentFilter:n.agentFilter,now:o,max:n.max}),i.candidates.length===0)return t("no unpromoted memories in window"),i;if(i.clusters=le(i.candidates),i.dryRun)return i;let l=p.articles.map(m=>({title:m.title,path:m.path,type:m.type})),d=c.getWorldview()??"",e=n.budgetTokens??ue,a=i.clusters,h=D(x,a,l,d);for(;R(h)>e&&a.length>1;)a=a.slice(0,-1),h=D(x,a,l,d);if(R(h)>e)return i.errors.push(`judge prompt (~${R(h)} tokens) exceeds the ${e}-token budget even with one cluster`),i;a.length<i.clusters.length&&i.warnings.push(`token budget: judged ${a.length} of ${i.clusters.length} clusters; the rest wait for the next run`);let y=a.flatMap(m=>m.candidates),w=new Set(y.map(m=>m.stamp)),b=n.chatId??`memory-promote-${new Date(o).toISOString().slice(0,10)}`,f=B(await G(h,{...n,chatId:b}),w);if("error"in f&&(t(`parse failed (${f.error}) \u2014 retrying with feedback`),f=B(await G(h,{...n,chatId:b},f.error),w)),"error"in f)return i.errors.push(`LLM response unusable after retry: ${f.error}`),i;i.warnings.push(...f.warnings),i.gaps=f.gaps;let v=new Date(o).toISOString(),k=[],T=new Map(y.map(m=>[m.stamp,m]));for(let m of f.articles){let A=c.readArticle(m.path);if(A&&!c.canWrite(A.meta,x)){i.errors.push(`write denied for "${m.path}" (owned by ${A.meta.owner??"?"})`);continue}let M=fe(m.promotedFrom,T),S={id:Y(o,m.path),createdAt:v,status:"pending",article:m,evidence:M,...A?{replaces:{lastUpdated:A.meta.lastUpdated,contentHash:V(A.content)}}:{}};I(r,S),i.proposed.push({id:S.id,path:m.path,title:m.title,type:m.type,stamps:m.promotedFrom,agents:M.agents,occurrences:M.occurrences});for(let X of m.promotedFrom)k.push({stamp:X,decision:"proposed",article:m.path,proposal:S.id,at:v})}for(let m of f.skipped)k.push({stamp:m.stamp,decision:"skipped",reason:m.reason,at:v}),i.skipped.push(m);return k.length&&C(r,k),i}var ue=6e4;function R(n){return Math.ceil(n.length/4)}function V(n){return ee("sha256").update(n).digest("hex").slice(0,16)}var he=600;function ye(n){return n.startsWith("review:")?"review":n.startsWith(j)?"failure":"memory"}function fe(n,r){let s=[];for(let t of n){let o=r.get(t);o&&s.push({stamp:t,kind:ye(t),agentId:o.agentId,type:o.memory.type,name:o.memory.name,description:o.memory.description,...o.occurrences?{occurrences:o.occurrences}:{},...o.sessions?.length?{sessions:o.sessions}:{},...o.tasks?.length?{tasks:o.tasks}:{},...o.failure?{failure:o.failure}:{},...o.memory.author?{author:o.memory.author}:{},...o.memory.taskId?{taskId:o.memory.taskId}:{},updatedAt:o.memory.updatedAt,excerpt:o.memory.body.slice(0,he)})}return{agents:[...new Set(s.map(t=>t.agentId))].sort(),occurrences:Math.max(1,...s.map(t=>t.occurrences??1)),sources:s}}function Ee(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=s.log??(()=>{}),i=new E(n,(...a)=>o(a.map(String).join(" "))),{article:c}=t,p=i.readArticle(c.path);if(!s.force){if(p&&!t.replaces)return{ok:!1,error:`"${c.path}" was created after this proposal; review it, then approve with --force`};if(p&&t.replaces&&V(p.content)!==t.replaces.contentHash)return{ok:!1,error:`"${c.path}" changed since this proposal; review it, then approve with --force`}}let u=s.now??Date.now(),g=new Date(u).toISOString().slice(0,10);if(!i.writeArticle(c.path,{title:c.title,type:L(c.type)?c.type:void 0,related:c.related,tags:c.tags,owner:x,access:"public",created:p?.meta.created??g,lastUpdated:g,sources:ae(p?.meta.sources,c.promotedFrom)},c.content,x))return{ok:!1,error:`write denied for "${c.path}" (owned by ${p?.meta.owner??"?"})`};let d=new Date(u).toISOString();C(n,c.promotedFrom.map(a=>({stamp:a,decision:"promoted",article:c.path,proposal:r,at:d}))),i.rebuildIndex();let e={...t,status:"approved",decidedBy:s.by??"operator",decidedAt:d};return I(n,e),{ok:!0,proposal:e}}function Oe(n,r,s={}){let t=O(n,r);if(!t)return{ok:!1,error:`no proposal "${r}"`};if(t.status!=="pending")return{ok:!1,error:`proposal "${r}" is already ${t.status}`};let o=new Date(s.now??Date.now()).toISOString();C(n,t.article.promotedFrom.map(c=>({stamp:c,decision:"rejected",article:t.article.path,proposal:r,reason:s.reason,at:o})));let i={...t,status:"rejected",decidedBy:s.by??"operator",decidedAt:o,...s.reason?{reason:s.reason}:{}};return I(n,i),{ok:!0,proposal:i}}export{be as a,x as b,oe as c,K as d,q as e,ie as f,$ as g,ae as h,ce as i,z as j,C as k,le as l,B as m,de as n,G as o,Se as p,R as q,ye as r,fe as s,Ee as t,Oe as u};
243
- //# sourceMappingURL=chunk-JVJYCR67.js.map
243
+ //# sourceMappingURL=chunk-3OIFSKSR.js.map
@@ -1,4 +1,4 @@
1
- import{b as S,c as O}from"./chunk-53J2D2ZJ.js";import{a as I,b as X}from"./chunk-FCPTN6NF.js";import{a as F,b as oe}from"./chunk-7I7IEX4S.js";import{d as M}from"./chunk-QIJLFPWE.js";import{execFile as Le}from"child_process";import{writeFileSync as ee,mkdirSync as w,existsSync as b,readFileSync as $e}from"fs";import{resolve as _}from"path";var ce=["off","shadow","authoritative"],ae={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},de="INTENT_LEDGER_MODE";function B(n,e=process.env){let t=P(e[ae[n]]);if(t)return t;let i=P(e[de]);return i||"off"}function P(n){if(typeof n!="string")return null;let e=n.trim().toLowerCase();return ce.includes(e)?e:null}X();import ue from"better-sqlite3";import{existsSync as Pe,mkdirSync as le}from"fs";import{dirname as ge,resolve as me}from"path";var T=class{db;path;constructor(e={}){this.path=me(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),le(ge(this.path),{recursive:!0}),this.db=new ue(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),fe(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let i=this.findEventBySourceId(e.source,e.sourceEventId);if(i)return i}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
1
+ import{b as S,c as O}from"./chunk-N2A3KIVY.js";import{a as I,b as X}from"./chunk-FCPTN6NF.js";import{a as F,b as oe}from"./chunk-7I7IEX4S.js";import{d as M}from"./chunk-QIJLFPWE.js";import{execFile as Le}from"child_process";import{writeFileSync as ee,mkdirSync as w,existsSync as b,readFileSync as $e}from"fs";import{resolve as _}from"path";var ce=["off","shadow","authoritative"],ae={telegram:"INTENT_LEDGER_MODE_TELEGRAM",slack:"INTENT_LEDGER_MODE_SLACK",whatsapp:"INTENT_LEDGER_MODE_WHATSAPP",discord:"INTENT_LEDGER_MODE_DISCORD",gitlab:"INTENT_LEDGER_MODE_GITLAB",github:"INTENT_LEDGER_MODE_GITHUB",workflow:"INTENT_LEDGER_MODE_WORKFLOW",cron:"INTENT_LEDGER_MODE_CRON",mesh:"INTENT_LEDGER_MODE_MESH"},de="INTENT_LEDGER_MODE";function B(n,e=process.env){let t=P(e[ae[n]]);if(t)return t;let i=P(e[de]);return i||"off"}function P(n){if(typeof n!="string")return null;let e=n.trim().toLowerCase();return ce.includes(e)?e:null}X();import ue from"better-sqlite3";import{existsSync as Pe,mkdirSync as le}from"fs";import{dirname as ge,resolve as me}from"path";var T=class{db;path;constructor(e={}){this.path=me(process.cwd(),e.path??".agentx/intent/ledger.sqlite"),le(ge(this.path),{recursive:!0}),this.db=new ue(this.path),this.db.pragma("journal_mode = WAL"),this.db.pragma("synchronous = NORMAL"),this.db.pragma("foreign_keys = ON"),fe(this.db)}close(){this.db.close()}schemaVersion(){return this.db.prepare("SELECT MAX(v) AS v FROM schema_version").get().v??0}recordEvent(e){if(e.sourceEventId!==null){let i=this.findEventBySourceId(e.source,e.sourceEventId);if(i)return i}let t={id:e.id??I(e.ts),ts:e.ts,source:e.source,sourceEventId:e.sourceEventId,project:e.project,subject:e.subject,intent:e.intent,rawJson:e.rawJson};return this.db.prepare(`INSERT INTO intent_events (id, ts, source, source_event_id, project, subject, intent, raw_json)
2
2
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)`).run(t.id,t.ts,t.source,t.sourceEventId,t.project,t.subject,t.intent,t.rawJson),t}findEventBySourceId(e,t){let i=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
3
3
  FROM intent_events WHERE source = ? AND source_event_id = ?`).get(e,t);return i?U(i):null}getEventById(e){let t=this.db.prepare(`SELECT id, ts, source, source_event_id, project, subject, intent, raw_json
4
4
  FROM intent_events WHERE id = ?`).get(e);return t?U(t):null}recordDecision(e){this.db.prepare(`INSERT INTO intent_decisions (event_id, decided_at, decided_by, agent_id, outcome, reason)
@@ -123,4 +123,4 @@ ${r.prompt}`,r.maxOutputTokens),agentId:r.agent,autonomy:r.autonomy,timeoutMinut
123
123
  `);return t.length<=e?t.join(`
124
124
  `):t.slice(-e).join(`
125
125
  `)}function Ce(n,e,t){return new Promise((i,r)=>{Le("/bin/sh",["-c",n],{timeout:e,maxBuffer:8*1024*1024,...t?{env:t}:{}},(s,c,o)=>{if(s&&s.killed){r(new Error(`command timed out after ${Math.round(e/1e3)}s`));return}i({stdout:String(c??""),stderr:String(o??""),code:s?typeof s.code=="number"?s.code:1:0})})})}export{T as a,G as b,it as c,De as d,rt as e,st as f,$ as g,Q as h,B as i,je as j,V as k,K as l,at as m,Ae as n,ne as o,ie as p,re as q,we as r,C as s};
126
- //# sourceMappingURL=chunk-FWDWHZ6H.js.map
126
+ //# sourceMappingURL=chunk-B5VRY4NI.js.map