agentix-cli 0.121.1 → 0.123.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 (122) hide show
  1. package/dist/{App-AMIGKAXO.js → App-NOCRE5SN.js} +2 -2
  2. package/dist/{ChatApp-WMI4HQSY.js → ChatApp-SETNTMED.js} +2 -2
  3. package/dist/{agent-KR4B2G24.js → agent-YII7XBL4.js} +2 -2
  4. package/dist/{board-dashboard-WBIQPRHQ.js → board-dashboard-BBLEP7OA.js} +338 -238
  5. package/dist/board-dashboard-BBLEP7OA.js.map +1 -0
  6. package/dist/{chunk-Y4PR5LR3.js → chunk-22SWFBSL.js} +2 -2
  7. package/dist/{chunk-MSYBNVY3.js → chunk-27FYNGDW.js} +2 -2
  8. package/dist/{chunk-FIB5LD6R.js → chunk-5HK3YJEQ.js} +257 -251
  9. package/dist/chunk-5HK3YJEQ.js.map +1 -0
  10. package/dist/{chunk-H5Z42X7W.js → chunk-AIYI2MFV.js} +2 -2
  11. package/dist/{chunk-6FVFD5WU.js → chunk-AKLZ4YO2.js} +4 -4
  12. package/dist/{chunk-6FVFD5WU.js.map → chunk-AKLZ4YO2.js.map} +1 -1
  13. package/dist/{chunk-HVYS5ZBQ.js → chunk-DTSKSYEO.js} +2 -2
  14. package/dist/{chunk-BLEW5WQL.js → chunk-EV2WPHHS.js} +2 -2
  15. package/dist/chunk-EYIQVQMA.js +37 -0
  16. package/dist/chunk-EYIQVQMA.js.map +1 -0
  17. package/dist/{chunk-ELUEF4NC.js → chunk-FQQHUCFN.js} +2 -2
  18. package/dist/{chunk-CAS2IWSM.js → chunk-GOCYZJMS.js} +2 -2
  19. package/dist/{chunk-6TUQHOO3.js → chunk-JA6MVY7J.js} +2 -2
  20. package/dist/{chunk-KFSA2ZI7.js → chunk-KQW2U5MY.js} +2 -2
  21. package/dist/{chunk-EI7D5V2L.js → chunk-LJ6ORTLS.js} +2 -2
  22. package/dist/{chunk-25XR6QK2.js → chunk-LRMUK6DC.js} +2 -2
  23. package/dist/chunk-M6WY53GO.js +532 -0
  24. package/dist/chunk-M6WY53GO.js.map +1 -0
  25. package/dist/{chunk-D7LGD7ZI.js → chunk-ODGGGU5J.js} +71 -69
  26. package/dist/chunk-ODGGGU5J.js.map +1 -0
  27. package/dist/{chunk-IKBWV7YJ.js → chunk-PGXACYDY.js} +2 -2
  28. package/dist/{chunk-OPNZWQ6Y.js → chunk-TEXZEXQZ.js} +11 -11
  29. package/dist/chunk-TEXZEXQZ.js.map +1 -0
  30. package/dist/{chunk-4GDLXWCH.js → chunk-TJLTPONY.js} +2 -2
  31. package/dist/{chunk-2IMK3NGJ.js → chunk-UNWXKBRF.js} +2 -2
  32. package/dist/{chunk-43CLFC4B.js → chunk-W3DCOYAE.js} +2 -2
  33. package/dist/{chunk-7ZABMMSW.js → chunk-WEPON4FP.js} +2 -2
  34. package/dist/{chunk-PAWCJIPZ.js → chunk-WXABFPX7.js} +2 -2
  35. package/dist/cli.js +1 -1
  36. package/dist/{client-ICDRAZBU.js → client-S67ZQ5FC.js} +2 -2
  37. package/dist/config-3AX5MHPN.js +2 -0
  38. package/dist/config-mutator-BYFMZQBT.js +2 -0
  39. package/dist/doctor-KFZLZRUN.js +2 -0
  40. package/dist/{editor-chat-4MLCP5D2.js → editor-chat-ELKNLXM6.js} +10 -3
  41. package/dist/{editor-chat-4MLCP5D2.js.map → editor-chat-ELKNLXM6.js.map} +1 -1
  42. package/dist/follow-up-tool-ZVEYUJ6U.js +6 -0
  43. package/dist/follow-up-tool-ZVEYUJ6U.js.map +1 -0
  44. package/dist/{grants-ZMHSJMYE.js → grants-HIFE6L5N.js} +2 -2
  45. package/dist/index.d.ts +216 -79
  46. package/dist/index.js +1 -1
  47. package/dist/{program-4J6WMXLI.js → program-VXR3YD5R.js} +211 -209
  48. package/dist/{program-4J6WMXLI.js.map → program-VXR3YD5R.js.map} +1 -1
  49. package/dist/{promote-4LW53AMH.js → promote-BQTJNRTG.js} +2 -2
  50. package/dist/push-bridge-325SXDGN.js +1 -1
  51. package/dist/{query-4OPS5PET.js → query-6YBM4TPV.js} +2 -2
  52. package/dist/{registry-XK2FTQZV.js → registry-B7OS4AOM.js} +2 -2
  53. package/dist/{request-planner-GDXSBNN4.js → request-planner-BLULDFMJ.js} +2 -2
  54. package/dist/{review-candidates-TUVDG2LR.js → review-candidates-HMQ6ZXBT.js} +2 -2
  55. package/dist/routing-WW56ZXGS.js +2 -0
  56. package/dist/schedule-tool-Y6RMN6ZT.js +2 -0
  57. package/dist/scheduler-4GB47SDH.js +2 -0
  58. package/dist/{seat-K6FNHYMY.js → seat-XGANYYMU.js} +2 -2
  59. package/dist/{select-QMJXHNUP.js → select-2HW6Q7UX.js} +2 -2
  60. package/dist/{set-enabled-I77LPL6Q.js → set-enabled-N5AGU5AH.js} +2 -2
  61. package/dist/tool-RJHDRV4X.js +6 -0
  62. package/dist/tool-RJHDRV4X.js.map +1 -0
  63. package/dist/{tool-QTGNWXUA.js → tool-XRV6IQ2J.js} +2 -2
  64. package/dist/web/workflow-editor.global.js +1 -1
  65. package/dist/web/workflow-editor.global.js.map +1 -1
  66. package/dist/wiki-ZA4FU3PW.js +2 -0
  67. package/package.json +1 -1
  68. package/dist/board-dashboard-WBIQPRHQ.js.map +0 -1
  69. package/dist/chunk-7KY7EEEI.js +0 -28
  70. package/dist/chunk-7KY7EEEI.js.map +0 -1
  71. package/dist/chunk-BWHHZJNJ.js +0 -482
  72. package/dist/chunk-BWHHZJNJ.js.map +0 -1
  73. package/dist/chunk-D7LGD7ZI.js.map +0 -1
  74. package/dist/chunk-FIB5LD6R.js.map +0 -1
  75. package/dist/chunk-OPNZWQ6Y.js.map +0 -1
  76. package/dist/config-K4UYPR7W.js +0 -2
  77. package/dist/config-mutator-IGA6D4S5.js +0 -2
  78. package/dist/doctor-LRTOOCM6.js +0 -2
  79. package/dist/routing-OKDZ4VYH.js +0 -2
  80. package/dist/schedule-tool-MJLXMXN5.js +0 -2
  81. package/dist/scheduler-E5SASFAH.js +0 -2
  82. package/dist/tool-BQUKONSF.js +0 -4
  83. package/dist/tool-BQUKONSF.js.map +0 -1
  84. package/dist/wiki-PAMLP6WO.js +0 -2
  85. /package/dist/{App-AMIGKAXO.js.map → App-NOCRE5SN.js.map} +0 -0
  86. /package/dist/{ChatApp-WMI4HQSY.js.map → ChatApp-SETNTMED.js.map} +0 -0
  87. /package/dist/{agent-KR4B2G24.js.map → agent-YII7XBL4.js.map} +0 -0
  88. /package/dist/{chunk-Y4PR5LR3.js.map → chunk-22SWFBSL.js.map} +0 -0
  89. /package/dist/{chunk-MSYBNVY3.js.map → chunk-27FYNGDW.js.map} +0 -0
  90. /package/dist/{chunk-H5Z42X7W.js.map → chunk-AIYI2MFV.js.map} +0 -0
  91. /package/dist/{chunk-HVYS5ZBQ.js.map → chunk-DTSKSYEO.js.map} +0 -0
  92. /package/dist/{chunk-BLEW5WQL.js.map → chunk-EV2WPHHS.js.map} +0 -0
  93. /package/dist/{chunk-ELUEF4NC.js.map → chunk-FQQHUCFN.js.map} +0 -0
  94. /package/dist/{chunk-CAS2IWSM.js.map → chunk-GOCYZJMS.js.map} +0 -0
  95. /package/dist/{chunk-6TUQHOO3.js.map → chunk-JA6MVY7J.js.map} +0 -0
  96. /package/dist/{chunk-KFSA2ZI7.js.map → chunk-KQW2U5MY.js.map} +0 -0
  97. /package/dist/{chunk-EI7D5V2L.js.map → chunk-LJ6ORTLS.js.map} +0 -0
  98. /package/dist/{chunk-25XR6QK2.js.map → chunk-LRMUK6DC.js.map} +0 -0
  99. /package/dist/{chunk-IKBWV7YJ.js.map → chunk-PGXACYDY.js.map} +0 -0
  100. /package/dist/{chunk-4GDLXWCH.js.map → chunk-TJLTPONY.js.map} +0 -0
  101. /package/dist/{chunk-2IMK3NGJ.js.map → chunk-UNWXKBRF.js.map} +0 -0
  102. /package/dist/{chunk-43CLFC4B.js.map → chunk-W3DCOYAE.js.map} +0 -0
  103. /package/dist/{chunk-7ZABMMSW.js.map → chunk-WEPON4FP.js.map} +0 -0
  104. /package/dist/{chunk-PAWCJIPZ.js.map → chunk-WXABFPX7.js.map} +0 -0
  105. /package/dist/{client-ICDRAZBU.js.map → client-S67ZQ5FC.js.map} +0 -0
  106. /package/dist/{config-K4UYPR7W.js.map → config-3AX5MHPN.js.map} +0 -0
  107. /package/dist/{config-mutator-IGA6D4S5.js.map → config-mutator-BYFMZQBT.js.map} +0 -0
  108. /package/dist/{doctor-LRTOOCM6.js.map → doctor-KFZLZRUN.js.map} +0 -0
  109. /package/dist/{grants-ZMHSJMYE.js.map → grants-HIFE6L5N.js.map} +0 -0
  110. /package/dist/{promote-4LW53AMH.js.map → promote-BQTJNRTG.js.map} +0 -0
  111. /package/dist/{query-4OPS5PET.js.map → query-6YBM4TPV.js.map} +0 -0
  112. /package/dist/{registry-XK2FTQZV.js.map → registry-B7OS4AOM.js.map} +0 -0
  113. /package/dist/{request-planner-GDXSBNN4.js.map → request-planner-BLULDFMJ.js.map} +0 -0
  114. /package/dist/{review-candidates-TUVDG2LR.js.map → review-candidates-HMQ6ZXBT.js.map} +0 -0
  115. /package/dist/{routing-OKDZ4VYH.js.map → routing-WW56ZXGS.js.map} +0 -0
  116. /package/dist/{schedule-tool-MJLXMXN5.js.map → schedule-tool-Y6RMN6ZT.js.map} +0 -0
  117. /package/dist/{scheduler-E5SASFAH.js.map → scheduler-4GB47SDH.js.map} +0 -0
  118. /package/dist/{seat-K6FNHYMY.js.map → seat-XGANYYMU.js.map} +0 -0
  119. /package/dist/{select-QMJXHNUP.js.map → select-2HW6Q7UX.js.map} +0 -0
  120. /package/dist/{set-enabled-I77LPL6Q.js.map → set-enabled-N5AGU5AH.js.map} +0 -0
  121. /package/dist/{tool-QTGNWXUA.js.map → tool-XRV6IQ2J.js.map} +0 -0
  122. /package/dist/{wiki-PAMLP6WO.js.map → wiki-ZA4FU3PW.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 E}from"./chunk-ELUEF4NC.js";import{c as R}from"./chunk-56KNKUFF.js";import{y as W,z as I}from"./chunk-4GDLXWCH.js";import{b as v,c as C}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 p=t.selectorModel??"haiku",g=t.synthModel??"sonnet",l=t.maxCandidates??3,r=t.maxHops??2,s=t.maxArticles??8,h=t.timeoutMs??6e4,u=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 N(q(n,e,l,m),p,h),f=K(y))}catch(c){return u("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 N(J(n,b),g,h*2)}catch(c){return u("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 Q=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:Q,selectorOutput:y}}}function A(n,a,o){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:o}}function F(n,a,o,t,p){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<p;){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 u of h.meta.related||[]){let m=g.get(u.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,p,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,p,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 ")})),u=await W(j,T({query:n,candidates:h,excerptChars:300}),D(h),{features:{agent:o??"unknown",stage:"catalog-selector"}});if(!u||u.mode!=="active")return null;let w=_(u.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 p=a.map(e=>[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")),g=C(n,v(p)),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?E(o,e.graphPath):0,u=(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(u),w=a.map((e,d)=>({i:d,score:h(e)})).filter(e=>!r.has(e.i)&&e.score>0).sort(u),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 p=t?.length?`
1
+ import{a as j,b as O,c as T,d as D,e as _,j as E}from"./chunk-FQQHUCFN.js";import{c as R}from"./chunk-56KNKUFF.js";import{y as W,z as I}from"./chunk-TJLTPONY.js";import{b as v,c as C}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 p=t.selectorModel??"haiku",g=t.synthModel??"sonnet",l=t.maxCandidates??3,r=t.maxHops??2,s=t.maxArticles??8,h=t.timeoutMs??6e4,u=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 N(q(n,e,l,m),p,h),f=K(y))}catch(c){return u("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 N(J(n,b),g,h*2)}catch(c){return u("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 Q=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:Q,selectorOutput:y}}}function A(n,a,o){return{answer:"",citations:[],candidates:[],walked:[],status:n,error:o}}function F(n,a,o,t,p){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<p;){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 u of h.meta.related||[]){let m=g.get(u.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,p,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,p,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 ")})),u=await W(j,T({query:n,candidates:h,excerptChars:300}),D(h),{features:{agent:o??"unknown",stage:"catalog-selector"}});if(!u||u.mode!=="active")return null;let w=_(u.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 p=a.map(e=>[e.title,(e.tags??[]).join(" "),(e.related??[]).join(" ")].join(" ")),g=C(n,v(p)),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?E(o,e.graphPath):0,u=(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(u),w=a.map((e,d)=>({i:d,score:h(e)})).filter(e=>!r.has(e.i)&&e.score>0).sort(u),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 p=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 N(n,a,o){let{writeFileSync:t,mkdirSync:p,rmSync:g}=await import("fs"),{tmpdir:l}=await import("os"),r=x(l(),`agentx-wiki-query-${process.pid}`);p(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"`,u=L(h,{env:R(),encoding:"utf-8",timeout:o,maxBuffer:4*1024*1024});try{let m=JSON.parse(u);return String(m.result||m.content||"")}catch{return u}}finally{try{g(s,{force:!0})}catch{}}}export{nt as a,$ as b,H as c};
49
- //# sourceMappingURL=chunk-Y4PR5LR3.js.map
49
+ //# sourceMappingURL=chunk-22SWFBSL.js.map
@@ -1,4 +1,4 @@
1
- import{c as ce,d as J,e as E,f as K,g as z}from"./chunk-SCJ5ZXEN.js";import{a as de,b as le}from"./chunk-BGG3ZSMW.js";import{b as ae}from"./chunk-WCXXXAHV.js";import{c as oe,e as ie}from"./chunk-LQE73AZR.js";import{i as F,k as se}from"./chunk-6FVFD5WU.js";import{a as ne,b as re}from"./chunk-2IMK3NGJ.js";import{a as te}from"./chunk-KFSA2ZI7.js";import{A as De,R as Z,Y as ze,ga as q,ia as ee,ja as W,ma as j,w as L,x as Q}from"./chunk-OPNZWQ6Y.js";import{existsSync as M,readFileSync as ve,writeFileSync as be,appendFileSync as Oe,mkdirSync as Be}from"fs";import{dirname as He,resolve as P}from"path";import{fileURLToPath as Le}from"url";import{hostname as qe}from"os";import{spawn as je}from"child_process";j();import{existsSync as ge,readFileSync as pe,writeFileSync as Y,copyFileSync as Me}from"fs";import{resolve as me}from"path";function U(e,t={}){let n=t.configPath||me(process.cwd(),"agentx.json");if(!ge(n))throw new Error(`agentx.json not found at ${n}`);let r=JSON.parse(pe(n,"utf-8")),a=e(r),o=typeof a=="string"?{summary:a}:a,s=JSON.stringify(r,null,2)+`
1
+ import{c as ce,d as J,e as E,f as K,g as z}from"./chunk-SCJ5ZXEN.js";import{a as de,b as le}from"./chunk-BGG3ZSMW.js";import{b as ae}from"./chunk-WCXXXAHV.js";import{c as oe,e as ie}from"./chunk-LQE73AZR.js";import{i as F,k as se}from"./chunk-AKLZ4YO2.js";import{a as ne,b as re}from"./chunk-UNWXKBRF.js";import{a as te}from"./chunk-KQW2U5MY.js";import{B as De,S as Z,Z as ze,ha as q,ja as ee,ka as W,na as j,w as L,x as Q}from"./chunk-TEXZEXQZ.js";import{existsSync as M,readFileSync as ve,writeFileSync as be,appendFileSync as Oe,mkdirSync as Be}from"fs";import{dirname as He,resolve as P}from"path";import{fileURLToPath as Le}from"url";import{hostname as qe}from"os";import{spawn as je}from"child_process";j();import{existsSync as ge,readFileSync as pe,writeFileSync as Y,copyFileSync as Me}from"fs";import{resolve as me}from"path";function U(e,t={}){let n=t.configPath||me(process.cwd(),"agentx.json");if(!ge(n))throw new Error(`agentx.json not found at ${n}`);let r=JSON.parse(pe(n,"utf-8")),a=e(r),o=typeof a=="string"?{summary:a}:a,s=JSON.stringify(r,null,2)+`
2
2
  `,l=n+".tmp";Y(l,s,"utf-8");try{JSON.parse(pe(l,"utf-8"))}catch(c){throw new Error(`config did not round-trip cleanly: ${c.message}`)}let i;return t.skipBackup||(i=`${n}.bak.${Date.now()}`,Me(n,i)),Y(n,s,"utf-8"),t.skipReload||Ne().catch(()=>{}),{summary:o.summary,payload:o.payload,backupPath:i}}function ue(e,t={}){let n=t.configPath||me(process.cwd(),"agentx.json");if(ge(n)&&!t.overwrite)throw new Error(`agentx.json already exists at ${n}. Pass overwrite=true to replace it.`);return Y(n,JSON.stringify(e,null,2)+`
3
3
  `,"utf-8"),{file:n}}async function Ne(){try{let t=W().dashboard.daemonUrl?.replace(/\/+$/,"")||"http://127.0.0.1:18800";await fetch(`${t}/reload`,{method:"POST"}).catch(()=>null)}catch{}}function fe(e,t){let n=e.configExists?e.agentCount===0?"Add your first agent":"Add another agent":"Set up your team",r=`<header class="ax-topbar">
4
4
  <div class="ax-topbar__left">
@@ -742,4 +742,4 @@ tr:hover td { background: var(--bg-hover); }
742
742
  WHERE person = ? AND state IN (${n.map(()=>"?").join(",")})
743
743
  ${r}`).all(t,...n,...a).map(s=>({id:s.id,state:s.state,channel:s.channel,agentId:s.agent_id,text:s.text,createdAt:s.created_at})):[]}function pn(e,t){return Ae(e,t,L,"ORDER BY created_at")}function gn(e,t,n=50){return Ae(e,t,[...L,...Q],"ORDER BY created_at DESC, rowid DESC LIMIT ?",Math.max(1,Math.min(n,500)))}ze();var V="member:",gt=90,mt="members",ut="tailscale-user-login",ft=400,ht=60*60*1e3;function vt(e){let t=e.scopes.find(n=>n.startsWith(V));return t?t.slice(V.length):null}function Ie(e,t){if(!e)return null;let n=t.verify(e),r=n?vt(n):null;return n&&r?{rec:n,personId:r}:null}function xn(e,t){let n=e.people().find(l=>l.id===t);if(!n)return{ok:!1,error:`No person "${t}". Add them first: agentx people add ${t} --name "\u2026"`};let{token:r,record:a}=e.tokens.create({name:`${n.name} (machine not paired yet)`,scopes:[`${V}${n.id}`],expiresInDays:gt}),{code:o,expiresAt:s}=e.codes.create({token:r,tokenId:a.id,name:n.id});return e.members.log({person:n.id,device:a.id,event:"invited"}),{ok:!0,code:o,expiresAt:s,tokenId:a.id,person:n}}var bt=Math.round(oe/6e4);function xt(e){return e==="client"?"Your project":"My work"}function yn(e){let t=xt(e.person.role),n=e.person.role==="client"?`I use AgentX to keep track of the work I do for you. It has a page for you, "${t}": what you asked us for, and where each request stands.`:`I use AgentX to give our AI agents their jobs. It has a page for you, "${t}": what you asked the agents for, and where each request stands.`;return[`Hi ${e.person.name},`,"",n,"","To open it:","1. Accept the Tailscale share I sent you. Tailscale is a small program that connects your computer to mine, privately.",`2. Open ${e.origin.replace(/\/+$/,"")}/member in Edge or Chrome, give your computer a name and type this code: ${ie(e.code)}`,` The code works once, for ${bt} minutes. If it has stopped working, tell me and I will send you a new one.`,"","I then approve your machine, and the page opens by itself."].join(`
744
744
  `)}var yt="The private network says someone else is connecting from this machine. Ask the person who invited you for a new code.",kt="Too many machines are waiting for the owner's answer. Try again later.",Se="That code didn't work. Check it, or ask the person who invited you for a new one.",Ee=(e,t)=>{let n=e.headers[t];return(Array.isArray(n)?n[0]:n||"").trim()};function Te(e){let t=e.socket?.remoteAddress||"";return t==="127.0.0.1"||t==="::1"||t==="::ffff:127.0.0.1"}function wt(e){if(!Te(e))return null;let t=Ee(e,ut).toLowerCase();return t?t.slice(0,80):null}function $t(e){let t=e.socket?.remoteAddress||"unknown";if(!Te(e))return t;let n=Ee(e,"x-forwarded-for").split(",").pop().trim();return/^[0-9a-fA-F:.]{2,45}$/.test(n)?n:t}function At(e){return typeof e=="string"?e.replace(/[^\p{L}\p{N} ._'()-]/gu," ").replace(/\s+/g," ").trim().slice(0,60):""}function St(e){return e.identities.map(Z).filter(t=>!!t&&t.channel==="tailscale").map(t=>t.value)}async function kn(e,t){let n=Date.now(),r=t.now??Date.now,a=t.log??(m=>console.log(m)),o=$t(e),s=t.limiter.retryAfter(o);if(s>0)return a(`[member] pair-code refused from ${o}: locked out for ${s}s more`),{status:429,body:{error:"too many attempts",retryAfter:s},retryAfter:s};let l=null,i="";try{let m=await ae(e,2048);l=m.code,i=At(m.machine)}catch{}let c=t.codes.redeem(l),g=c?Ie(c.token,t.tokens):null;if(await Et(n,t.minMs??ft),!c||!g)return t.limiter.fail(o),a(`[member] pair-code failed from ${o}`),{status:401,body:{error:Se}};t.limiter.succeed(o);let{rec:f,personId:d}=g,h=t.people().find(m=>m.id===d);if(!h)return t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:"person no longer listed"}),a(`[member] pair-code for ${d} refused from ${o}: person no longer listed`),{status:403,body:{error:Se}};let u=wt(e),A=St(h);if(A.length&&(!u||!A.includes(u)))return t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:`network login ${u??"missing"}; expected ${A.join(" or ")}`}),a(`[member] ${d}: pairing from ${o} refused: the network says "${u??"nobody"}", expected ${A.join(" or ")}`),{status:403,body:{error:yt}};let x=i||"Unnamed machine",y=h.name.slice(0,40),v=se(t.root,{title:`New machine for ${y}`,ask:`From ${o}, ${u?`network login ${u}`:"no network login reported"}. Machine name, as typed there: "${x}". Let it see ${y}'s own work?`,recommend:`Yes if ${y} told you they just paired this machine. No if you did not expect it.`,if_silent:"discard",raised_by:mt},{now:r()});return v.ok?(t.members.add({tokenId:f.id,personId:d,name:x,state:"pending",cardId:v.card.id,address:o,...u?{network:u}:{},createdAt:new Date(r()).toISOString()}),t.members.log({person:d,device:f.id,event:"paired",address:o,detail:x}),a(`[member] ${d} paired "${x}" from ${o}; waiting for the owner (card ${v.card.id})`),{status:200,body:{person:d,name:x,state:"pending"},token:c.token}):(t.tokens.revoke(f.id),t.members.log({person:d,device:f.id,event:"refused",address:o,detail:v.error}),a(`[member] ${d}: pairing from ${o} refused: ${v.error}`),{status:503,body:{error:kt}})}var H="this machine is not paired",It="waiting for the owner to approve this machine";function Ce(e){return e?e.status==="decided"?e.verdict??null:e.status==="expired"?"no":null:null}function wn(e,t){return t.state==="pending"&&t.cardId?Ce(F(e,t.cardId)):null}function $n(e,t,n){let r=t.now??Date.now,a=t.log??(g=>console.log(g)),o=Ie(e,t.tokens);if(!o)return{ok:!1,status:401,error:H};let{rec:s,personId:l}=o,i=t.members.byToken(s.id);if(!i||i.state==="removed"||i.personId!==l)return{ok:!1,status:401,error:H};if(t.people&&!t.people().some(g=>g.id===l))return Re(t,s.id,"person no longer listed"),a(`[member] ${l}: "${i.name}" ended: person no longer listed`),{ok:!1,status:401,error:H};if(i.state==="pending"){let g=i.cardId?F(t.root,i.cardId):null,f=Ce(g);if(f==="yes")i=t.members.update(s.id,{state:"active",approvedAt:new Date(r()).toISOString()})??i,t.members.log({person:l,device:s.id,event:"approved",detail:g?.decided_by}),a(`[member] ${l}: "${i.name}" approved`);else if(f==="no"){let d=g?.status==="expired"?"the owner did not answer in time":"the owner said no";return t.tokens.revoke(s.id),t.members.update(s.id,{state:"removed",removedAt:new Date(r()).toISOString(),removedReason:d}),t.members.log({person:l,device:s.id,event:"refused",detail:d}),a(`[member] ${l}: "${i.name}" refused: ${d}`),{ok:!1,status:401,error:H}}else return{ok:!1,status:403,error:It,waiting:!0}}let c=i.lastSeenAt?Date.parse(i.lastSeenAt):0;return n&&(r()-c>=ht||i.lastAddress!==n)&&(i=t.members.update(s.id,{lastSeenAt:new Date(r()).toISOString(),lastAddress:n})??i,t.members.log({person:l,device:s.id,event:"signed-in",address:n})),{ok:!0,device:i,personId:l,rec:s}}function Re(e,t,n="removed by the owner"){let r=e.members.byToken(t);if(!r)return null;e.tokens.revoke(t);let a=e.members.update(t,{state:"removed",removedAt:new Date((e.now??Date.now)()).toISOString(),removedReason:n});return e.members.log({person:r.personId,device:t,event:"removed",detail:n}),a}function An(e,t){return e.members.devices(t).filter(n=>n.state!=="removed").map(n=>Re(e,n.tokenId,"person removed by the owner")).filter(n=>!!n)}async function Et(e,t){let n=e+t-Date.now();n>0&&await new Promise(r=>setTimeout(r,n))}var Pe=["gitlab","github"];function Tt(e,t,n){let r=String(t||"").trim().toLowerCase();if(!Pe.includes(r))throw new Error(`Request status works on ${Pe.join(" and ")}, not on "${t}".`);e.requestStatus=e.requestStatus&&typeof e.requestStatus=="object"?e.requestStatus:{};let a=Array.isArray(e.requestStatus.channels)?e.requestStatus.channels.map(o=>String(o).toLowerCase()):[];return e.requestStatus.channels=n?[...new Set([...a,r])]:a.filter(o=>o!==r),`request status on ${r} is ${n?"on":"off"}`}function En(e){return Array.isArray(e?.requestStatus?.channels)?e.requestStatus.channels.map(t=>String(t).toLowerCase()):[]}function Tn(e){let{summary:t}=U(n=>Tt(n,e?.channel,!!e?.enabled));return{summary:t}}var Ct="https://ntfy.sh";function Rn(e){return{enabled:!!e?.enabled,server:e?.server||Ct,topicSet:!!e?.topic,tokenSet:!!e?.token}}function Pn(e,t){let n={...e??{}};if("enabled"in t&&(n.enabled=!!t.enabled),"server"in t){let r=String(t.server).trim().replace(/\/+$/,"");if(!/^https?:\/\/\S+$/.test(r))throw new Error("ntfy server must be an http(s) URL");n.server=r}if("topic"in t){let r=String(t.topic).trim();if(!r)throw new Error("ntfy topic cannot be empty");n.topic=r}if("token"in t){let r=String(t.token??"").trim();r?n.token=r:delete n.token}if(n.enabled&&!n.topic)throw new Error("set a topic before enabling ntfy");return n}export{U as a,xe as b,jt as c,Ft as d,Jt as e,Vt as f,Qt as g,Zt as h,cn as i,pn as j,gn as k,gt as l,xn as m,bt as n,xt as o,yn as p,$t as q,kn as r,wn as s,$n as t,Re as u,An as v,Pe as w,Tt as x,En as y,Tn as z,Rn as A,Pn as B,lt as C,sn as D};
745
- //# sourceMappingURL=chunk-MSYBNVY3.js.map
745
+ //# sourceMappingURL=chunk-27FYNGDW.js.map