@axhub/genie 0.2.8 → 0.2.10
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.
- package/LICENSE +21 -675
- package/dist/api-docs.html +2 -2
- package/dist/assets/App-CYCCsgwf.js +264 -0
- package/dist/assets/ReviewApp-0srHIXwb.js +1 -0
- package/dist/assets/{_basePickBy-CqJbRZ9y.js → _basePickBy-DVVb07UV.js} +1 -1
- package/dist/assets/{_baseUniq-BS8YH8jO.js → _baseUniq-BtbziL5G.js} +1 -1
- package/dist/assets/{arc-BBmKEN-S.js → arc-BsCC8yBD.js} +1 -1
- package/dist/assets/{architectureDiagram-2XIMDMQ5-N5lcb82R.js → architectureDiagram-2XIMDMQ5-woFp6eNI.js} +1 -1
- package/dist/assets/{blockDiagram-WCTKOSBZ-DTMwHuLn.js → blockDiagram-WCTKOSBZ-ya8VAc2k.js} +1 -1
- package/dist/assets/{c4Diagram-IC4MRINW-BTKlkXI9.js → c4Diagram-IC4MRINW-CY1dZmIZ.js} +1 -1
- package/dist/assets/channel-BMhScXFe.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-DUdoTxAc.js → chunk-4BX2VUAB-CR1lAd74.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-Bm_92xe4.js → chunk-55IACEB6-CP98WcFC.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-CGW0g62g.js → chunk-FMBD7UC4-D9c7ijAB.js} +1 -1
- package/dist/assets/{chunk-JSJVCQXG-DYkTH3w1.js → chunk-JSJVCQXG-DQAGYOn-.js} +1 -1
- package/dist/assets/{chunk-KX2RTZJC-C9oTlISU.js → chunk-KX2RTZJC-BbTXiDq7.js} +1 -1
- package/dist/assets/{chunk-NQ4KR5QH-CM50ygWP.js → chunk-NQ4KR5QH-BI6AX0dr.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-7dzpYeNJ.js → chunk-QZHKN3VN-DB3V2Ifo.js} +1 -1
- package/dist/assets/{chunk-WL4C6EOR-Cm9nQrsr.js → chunk-WL4C6EOR-DhzTthv6.js} +1 -1
- package/dist/assets/classDiagram-VBA2DB6C-CMIxlWcT.js +1 -0
- package/dist/assets/classDiagram-v2-RAHNMMFH-CMIxlWcT.js +1 -0
- package/dist/assets/clone-BPqOt4r3.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-Ccp_p0JZ.js → cose-bilkent-S5V4N54A-BQ09ZE2j.js} +1 -1
- package/dist/assets/{dagre-KLK3FWXG-fBwTLUp9.js → dagre-KLK3FWXG-Dc2ueD_R.js} +1 -1
- package/dist/assets/{diagram-E7M64L7V-CeNVmFUp.js → diagram-E7M64L7V-DP-LsQoL.js} +1 -1
- package/dist/assets/{diagram-IFDJBPK2-CtavyLGa.js → diagram-IFDJBPK2-Cg6r42cB.js} +1 -1
- package/dist/assets/{diagram-P4PSJMXO-CpQTjQwc.js → diagram-P4PSJMXO-aHsfoUZE.js} +1 -1
- package/dist/assets/{erDiagram-INFDFZHY-B8R5vwhd.js → erDiagram-INFDFZHY-qBXJ4aAz.js} +1 -1
- package/dist/assets/{flowDiagram-PKNHOUZH-BvkVVwIQ.js → flowDiagram-PKNHOUZH-D_13emJM.js} +1 -1
- package/dist/assets/{ganttDiagram-A5KZAMGK-DOu3hSNa.js → ganttDiagram-A5KZAMGK-BvIcOLwz.js} +1 -1
- package/dist/assets/{gitGraphDiagram-K3NZZRJ6-C7zT67YE.js → gitGraphDiagram-K3NZZRJ6-ad0vvNcU.js} +1 -1
- package/dist/assets/{graph-D11wiwHo.js → graph-CeJCMjan.js} +1 -1
- package/dist/assets/{highlighted-body-TPN3WLV5-Babpthg-.js → highlighted-body-TPN3WLV5-B_novwSz.js} +1 -1
- package/dist/assets/index-C514cLyb.js +2 -0
- package/dist/assets/index-h1DBl_g3.css +1 -0
- package/dist/assets/{infoDiagram-LFFYTUFH-BmA7IpQG.js → infoDiagram-LFFYTUFH-lOxAqb3m.js} +1 -1
- package/dist/assets/{ishikawaDiagram-PHBUUO56-BEquZd3E.js → ishikawaDiagram-PHBUUO56-DIr-51gj.js} +1 -1
- package/dist/assets/{journeyDiagram-4ABVD52K-BfemGz7f.js → journeyDiagram-4ABVD52K-CYcIW0ZU.js} +1 -1
- package/dist/assets/{kanban-definition-K7BYSVSG-CWja3mln.js → kanban-definition-K7BYSVSG-C1ZK616a.js} +1 -1
- package/dist/assets/{layout-BLUNf-PJ.js → layout-CI2RM-v6.js} +1 -1
- package/dist/assets/{linear-DukIV_Xv.js → linear-DE7bISck.js} +1 -1
- package/dist/assets/{mermaid-O7DHMXV3-SgtM28qI.js → mermaid-O7DHMXV3-XxAJo8EK.js} +6 -6
- package/dist/assets/{mindmap-definition-YRQLILUH-4UjqXITU.js → mindmap-definition-YRQLILUH-Dz6EFjmn.js} +1 -1
- package/dist/assets/{pieDiagram-SKSYHLDU-8AxqJd0M.js → pieDiagram-SKSYHLDU-DPpEzUed.js} +1 -1
- package/dist/assets/{quadrantDiagram-337W2JSQ-D60m8V8r.js → quadrantDiagram-337W2JSQ-xdoXNet7.js} +1 -1
- package/dist/assets/{requirementDiagram-Z7DCOOCP-zqh9jBVf.js → requirementDiagram-Z7DCOOCP-DUq8H3CL.js} +1 -1
- package/dist/assets/{sankeyDiagram-WA2Y5GQK-CDZILTLI.js → sankeyDiagram-WA2Y5GQK-CmqEUxRu.js} +1 -1
- package/dist/assets/{sequenceDiagram-2WXFIKYE-7BReFd0L.js → sequenceDiagram-2WXFIKYE-DhtXRNiH.js} +1 -1
- package/dist/assets/{stateDiagram-RAJIS63D-HPTVdIG4.js → stateDiagram-RAJIS63D-Dj0HOlbN.js} +1 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-C9utf5gv.js +1 -0
- package/dist/assets/{timeline-definition-YZTLITO2-CTVllFgr.js → timeline-definition-YZTLITO2-DUuJzZB5.js} +1 -1
- package/dist/assets/{treemap-KZPCXAKY-BtyxboJZ.js → treemap-KZPCXAKY-DpYBQ0qr.js} +1 -1
- package/dist/assets/vendor-codemirror-CMHSJ_9p.js +9 -0
- package/dist/assets/{vendor-react-Cpt6D04s.js → vendor-react-xmA_f8ig.js} +1 -1
- package/dist/assets/{vennDiagram-LZ73GAT5-D96ZI6Mg.js → vennDiagram-LZ73GAT5-DpePUyOd.js} +1 -1
- package/dist/assets/{xychartDiagram-JWTSCODW-eRk-39YO.js → xychartDiagram-JWTSCODW-Cfp1I4_U.js} +1 -1
- package/dist/index.html +5 -5
- package/package.json +8 -7
- package/server/acp-runtime/client.js +129 -16
- package/server/acp-runtime/index.js +54 -0
- package/server/acp-runtime/registry.js +2 -2
- package/server/acp-runtime/session-store.js +79 -5
- package/server/cli.js +55 -10
- package/server/database/db.js +20 -0
- package/server/external-agent/service.js +24 -6
- package/server/external-agent/ws.js +540 -27
- package/server/index.js +112 -151
- package/server/lan-access/core.js +79 -0
- package/server/lan-access/state.js +102 -0
- package/server/middleware/auth.js +57 -14
- package/server/projects.js +930 -667
- package/server/routes/auth.js +24 -4
- package/server/routes/cli-auth.js +21 -25
- package/server/routes/codex.js +84 -298
- package/server/routes/commands.js +322 -407
- package/server/routes/lan-access.js +231 -0
- package/server/routes/projects.js +154 -158
- package/server/routes/session-core.js +160 -91
- package/server/routes/settings.js +113 -99
- package/server/session-core/eventStore.js +60 -20
- package/server/session-core/providerAdapters.js +75 -38
- package/server/session-core/runtimeState.js +8 -0
- package/server/session-core/sessionListMerge.js +47 -0
- package/shared/conversationEvents.js +174 -15
- package/shared/modelConstants.js +79 -99
- package/dist/assets/App-CTKZtqB1.js +0 -460
- package/dist/assets/ReviewApp-DM6BNAzR.js +0 -1
- package/dist/assets/channel-1oJBvF-0.js +0 -1
- package/dist/assets/classDiagram-VBA2DB6C-d5TeKFM4.js +0 -1
- package/dist/assets/classDiagram-v2-RAHNMMFH-d5TeKFM4.js +0 -1
- package/dist/assets/clone-CinxIlEu.js +0 -1
- package/dist/assets/index-DFxzgWoO.js +0 -2
- package/dist/assets/index-YCFGDVKw.css +0 -1
- package/dist/assets/stateDiagram-v2-FVOUBMTO-DTUf5_gC.js +0 -1
- package/dist/assets/vendor-codemirror-Dz7_EqNA.js +0 -39
- package/server/_legacy-providers/README.md +0 -30
- package/server/_legacy-providers/claude-sdk.js +0 -956
- package/server/_legacy-providers/gemini-cli.js +0 -368
- package/server/_legacy-providers/openai-codex.js +0 -705
- package/server/_legacy-providers/opencode-cli.js +0 -674
- package/server/routes/git.js +0 -1110
- package/server/routes/mcp-utils.js +0 -48
- package/server/routes/mcp.js +0 -536
- package/server/routes/taskmaster.js +0 -1963
- package/server/utils/mcp-detector.js +0 -198
- package/server/utils/taskmaster-websocket.js +0 -129
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{aO as Gt,_ as w,s as Wt,g as Kt,t as Ht,q as Yt,a as Xt,b as Zt,K as wt,N as Jt,d as ot,av as Qt,ag as $t,ah as te,ai as ee,e as ne,A as se,H as ie,L as oe}from"./mermaid-O7DHMXV3-SgtM28qI.js";import"./vendor-react-Cpt6D04s.js";import"./vendor-codemirror-Dz7_EqNA.js";import"./index-DFxzgWoO.js";const kt=(t,n)=>Gt(t,"a",-n),_t=1e-10;function st(t,n){const s=ae(t),e=s.filter(c=>re(c,t));let i=0,o=0;const a=[];if(e.length>1){const c=Et(e);for(let u=0;u<e.length;++u){const r=e[u];r.angle=Math.atan2(r.x-c.x,r.y-c.y)}e.sort((u,r)=>r.angle-u.angle);let h=e[e.length-1];for(let u=0;u<e.length;++u){const r=e[u];o+=(h.x+r.x)*(r.y-h.y);const y={x:(r.x+h.x)/2,y:(r.y+h.y)/2};let d=null;for(let b=0;b<r.parentIndex.length;++b)if(h.parentIndex.includes(r.parentIndex[b])){const x=t[r.parentIndex[b]],M=Math.atan2(r.x-x.x,r.y-x.y),A=Math.atan2(h.x-x.x,h.y-x.y);let T=A-M;T<0&&(T+=2*Math.PI);const S=A-T/2;let g=q(y,{x:x.x+x.radius*Math.sin(S),y:x.y+x.radius*Math.cos(S)});g>x.radius*2&&(g=x.radius*2),(d==null||d.width>g)&&(d={circle:x,width:g,p1:r,p2:h,large:g>x.radius,sweep:!0})}d!=null&&(a.push(d),i+=lt(d.circle.radius,d.width),h=r)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let h=!1;for(let u=0;u<t.length;++u)if(q(t[u],c)>Math.abs(c.radius-t[u].radius)){h=!0;break}h?i=o=0:(i=c.radius*c.radius*Math.PI,a.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-_t,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return o/=2,n&&(n.area=i+o,n.arcArea=i,n.polygonArea=o,n.arcs=a,n.innerPoints=e,n.intersectionPoints=s),i+o}function re(t,n){return n.every(s=>q(t,s)<s.radius+_t)}function ae(t){const n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){const i=Tt(t[s],t[e]);for(const o of i)o.parentIndex=[s,e],n.push(o)}return n}function lt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function q(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function xt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);const e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return lt(t,e)+lt(n,i)}function Tt(t,n){const s=q(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];const o=(e*e-i*i+s*s)/(2*s),a=Math.sqrt(e*e-o*o),c=t.x+o*(n.x-t.x)/s,h=t.y+o*(n.y-t.y)/s,u=-(n.y-t.y)*(a/s),r=-(n.x-t.x)*(a/s);return[{x:c+u,y:h-r},{x:c-u,y:h+r}]}function Et(t){const n={x:0,y:0};for(const s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}function le(t,n,s,e){e=e||{};const i=e.maxIterations||100,o=e.tolerance||1e-10,a=t(n),c=t(s);let h=s-n;if(a*c>0)throw"Initial bisect points must have opposite signs";if(a===0)return n;if(c===0)return s;for(let u=0;u<i;++u){h/=2;const r=n+h,y=t(r);if(y*a>=0&&(n=r),Math.abs(h)<o||y===0)return r}return n+h}function ct(t){const n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}function Mt(t,n){return ct(t).map(()=>ct(n))}function $(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}function ut(t){return Math.sqrt($(t,t))}function ft(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}function J(t,n,s,e,i){for(let o=0;o<t.length;++o)t[o]=n*s[o]+e*i[o]}function zt(t,n,s){s=s||{};const e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,o=s.zeroDelta||.001,a=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,h=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,r=s.psi!==void 0?s.psi:-.5,y=s.sigma!==void 0?s.sigma:.5;let d;const b=n.length,x=new Array(b+1);x[0]=n,x[0].fx=t(n),x[0].id=0;for(let v=0;v<b;++v){const l=n.slice();l[v]=l[v]?l[v]*i:o,x[v+1]=l,x[v+1].fx=t(l),x[v+1].id=v+1}function M(v){for(let l=0;l<v.length;l++)x[b][l]=v[l];x[b].fx=v.fx}const A=(v,l)=>v.fx-l.fx,T=n.slice(),S=n.slice(),g=n.slice(),m=n.slice();for(let v=0;v<e;++v){if(x.sort(A),s.history){const p=x.map(f=>{const N=f.slice();return N.fx=f.fx,N.id=f.id,N});p.sort((f,N)=>f.id-N.id),s.history.push({x:x[0].slice(),fx:x[0].fx,simplex:p})}d=0;for(let p=0;p<b;++p)d=Math.max(d,Math.abs(x[0][p]-x[1][p]));if(Math.abs(x[0].fx-x[b].fx)<a&&d<c)break;for(let p=0;p<b;++p){T[p]=0;for(let f=0;f<b;++f)T[p]+=x[f][p];T[p]/=b}const l=x[b];if(J(S,1+h,T,-h,l),S.fx=t(S),S.fx<x[0].fx)J(m,1+u,T,-u,l),m.fx=t(m),m.fx<S.fx?M(m):M(S);else if(S.fx>=x[b-1].fx){let p=!1;if(S.fx>l.fx?(J(g,1+r,T,-r,l),g.fx=t(g),g.fx<l.fx?M(g):p=!0):(J(g,1-r*h,T,r*h,l),g.fx=t(g),g.fx<S.fx?M(g):p=!0),p){if(y>=1)break;for(let f=1;f<x.length;++f)J(x[f],1-y,x[0],y,x[f]),x[f].fx=t(x[f])}}else M(S)}return x.sort(A),{fx:x[0].fx,x:x[0]}}function ce(t,n,s,e,i,o,a){const c=s.fx,h=$(s.fxprime,n);let u=c,r=c,y=h,d=0;i=i||1,o=o||1e-6,a=a||.1;function b(x,M,A){for(let T=0;T<16;++T)if(i=(x+M)/2,J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=$(e.fxprime,n),u>c+o*i*h||u>=A)M=i;else{if(Math.abs(y)<=-a*h)return i;y*(M-x)>=0&&(M=x),x=i,A=u}return 0}for(let x=0;x<10;++x){if(J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=$(e.fxprime,n),u>c+o*i*h||x&&u>=r)return b(d,i,r);if(Math.abs(y)<=-a*h)return i;if(y>=0)return b(i,d,u);r=u,d=i,i*=2}return i}function ue(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()};const o=n.slice();let a,c,h=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),a=e.fxprime.slice(),ft(a,e.fxprime,-1);for(let r=0;r<u;++r){if(h=ce(t,a,e,i,h),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),!h)ft(a,e.fxprime,-1);else{J(o,1,i.fxprime,-1,e.fxprime);const y=$(e.fxprime,e.fxprime),d=Math.max(0,$(o,i.fxprime)/y);J(a,d,a,-1,i.fxprime),c=e,e=i,i=c}if(ut(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),e}function At(t,n={}){n.maxIterations=n.maxIterations||500;const s=n.initialLayout||ge,e=n.lossFunction||tt,i=fe(t,n),o=s(i,n),a=Object.keys(o),c=[];for(const r of a)c.push(o[r].x),c.push(o[r].y);const u=zt(r=>{const y={};for(let d=0;d<a.length;++d){const b=a[d];y[b]={x:r[2*d],y:r[2*d+1],radius:o[b].radius}}return e(y,i)},c,n).x;for(let r=0;r<a.length;++r){const y=a[r];o[y].x=u[2*r],o[y].y=u[2*r+1]}return o}const Rt=1e-10;function ht(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Rt?Math.abs(t-n):le(e=>xt(t,n,e)-s,0,t+n)}function fe(t,n={}){const s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(s){const c=new Map;for(const h of e)for(let u=0;u<h.sets.length;u++){const r=String(h.sets[u]);c.set(r,h.size+(c.get(r)||0));for(let y=u+1;y<h.sets.length;y++){const d=String(h.sets[y]),b=`${r};${d}`,x=`${d};${r}`;c.set(b,h.size+(c.get(b)||0)),c.set(x,h.size+(c.get(x)||0))}}for(const h of e)h.sets.length<3&&(h.size=c.get(i(h.sets)))}const o=[],a=new Set;for(const c of e)if(c.sets.length===1)o.push(c.sets[0]);else if(c.sets.length===2){const h=c.sets[0],u=c.sets[1];a.add(i(c.sets)),a.add(i([u,h]))}o.sort((c,h)=>c===h?0:c<h?-1:1);for(let c=0;c<o.length;++c){const h=o[c];for(let u=c+1;u<o.length;++u){const r=o[u];a.has(i([h,r]))||e.push({sets:[h,r],size:0})}}return e}function he(t,n,s){const e=Mt(n.length,n.length),i=Mt(n.length,n.length);return t.filter(o=>o.sets.length===2).forEach(o=>{const a=s[o.sets[0]],c=s[o.sets[1]],h=Math.sqrt(n[a].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),r=ht(h,u,o.size);e[a][c]=e[c][a]=r;let y=0;o.size+1e-10>=Math.min(n[a].size,n[c].size)?y=1:o.size<=1e-10&&(y=-1),i[a][c]=i[c][a]=y}),{distances:e,constraints:i}}function de(t,n,s,e){for(let o=0;o<n.length;++o)n[o]=0;let i=0;for(let o=0;o<s.length;++o){const a=t[2*o],c=t[2*o+1];for(let h=o+1;h<s.length;++h){const u=t[2*h],r=t[2*h+1],y=s[o][h],d=e[o][h],b=(u-a)*(u-a)+(r-c)*(r-c),x=Math.sqrt(b),M=b-y*y;d>0&&x<=y||d<0&&x>=y||(i+=2*M*M,n[2*o]+=4*M*(a-u),n[2*o+1]+=4*M*(c-r),n[2*h]+=4*M*(u-a),n[2*h+1]+=4*M*(r-c))}}return i}function ge(t,n={}){let s=ye(t,n);const e=n.lossFunction||tt;if(t.length>=8){const i=xe(t,n),o=e(i,t),a=e(s,t);o+1e-8<a&&(s=i)}return s}function xe(t,n={}){const s=n.restarts||10,e=[],i={};for(const d of t)d.sets.length===1&&(i[d.sets[0]]=e.length,e.push(d));let{distances:o,constraints:a}=he(t,e,i);const c=ut(o.map(ut))/o.length;o=o.map(d=>d.map(b=>b/c));const h=(d,b)=>de(d,b,o,a);let u=null;for(let d=0;d<s;++d){const b=ct(o.length*2).map(Math.random),x=ue(h,b,n);(!u||x.fx<u.fx)&&(u=x)}const r=u.x,y={};for(let d=0;d<e.length;++d){const b=e[d];y[b.sets[0]]={x:r[2*d]*c,y:r[2*d+1]*c,radius:Math.sqrt(b.size/Math.PI)}}if(n.history)for(const d of n.history)ft(d.x,c);return y}function ye(t,n){const s=n&&n.lossFunction?n.lossFunction:tt,e={},i={};for(const y of t)if(y.sets.length===1){const d=y.sets[0];e[d]={x:1e10,y:1e10,rowid:e.length,size:y.size,radius:Math.sqrt(y.size/Math.PI)},i[d]=[]}t=t.filter(y=>y.sets.length===2);for(const y of t){let d=y.weight!=null?y.weight:1;const b=y.sets[0],x=y.sets[1];y.size+Rt>=Math.min(e[b].size,e[x].size)&&(d=0),i[b].push({set:x,size:y.size,weight:d}),i[x].push({set:b,size:y.size,weight:d})}const o=[];Object.keys(i).forEach(y=>{let d=0;for(let b=0;b<i[y].length;++b)d+=i[y][b].size*i[y][b].weight;o.push({set:y,size:d})});function a(y,d){return d.size-y.size}o.sort(a);const c={};function h(y){return y.set in c}function u(y,d){e[d].x=y.x,e[d].y=y.y,c[d]=!0}u({x:0,y:0},o[0].set);for(let y=1;y<o.length;++y){const d=o[y].set,b=i[d].filter(h),x=e[d];if(b.sort(a),b.length===0)throw"ERROR: missing pairwise overlap information";const M=[];for(var r=0;r<b.length;++r){const S=e[b[r].set],g=ht(x.radius,S.radius,b[r].size);M.push({x:S.x+g,y:S.y}),M.push({x:S.x-g,y:S.y}),M.push({y:S.y+g,x:S.x}),M.push({y:S.y-g,x:S.x});for(let m=r+1;m<b.length;++m){const v=e[b[m].set],l=ht(x.radius,v.radius,b[m].size),p=Tt({x:S.x,y:S.y,radius:g},{x:v.x,y:v.y,radius:l});M.push(...p)}}let A=1e50,T=M[0];for(const S of M){e[d].x=S.x,e[d].y=S.y;const g=s(e,t);g<A&&(A=g,T=S)}u(T,d)}return e}function tt(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const a=t[e.sets[0]],c=t[e.sets[1]];i=xt(a.radius,c.radius,q(a,c))}else i=st(e.sets.map(a=>t[a]));const o=e.weight!=null?e.weight:1;s+=o*(i-e.size)*(i-e.size)}return s}function Ct(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const c=t[e.sets[0]],h=t[e.sets[1]];i=xt(c.radius,h.radius,q(c,h))}else i=st(e.sets.map(c=>t[c]));const o=e.weight!=null?e.weight:1,a=Math.log((i+1)/(e.size+1));s+=o*a*a}return s}function pe(t,n,s){if(s==null?t.sort((i,o)=>o.radius-i.radius):t.sort(s),t.length>0){const i=t[0].x,o=t[0].y;for(const a of t)a.x-=i,a.y-=o}if(t.length===2&&q(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const i=Math.atan2(t[1].x,t[1].y)-n,o=Math.cos(i),a=Math.sin(i);for(const c of t){const h=c.x,u=c.y;c.x=o*h-a*u,c.y=a*h+o*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){const o=t[1].y/(1e-10+t[1].x);for(const a of t){var e=(a.x+o*a.y)/(1+o*o);a.x=2*e-a.x,a.y=2*e*o-a.y}}}}function me(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}function s(i,o){const a=n(i),c=n(o);a.parent=c}for(let i=0;i<t.length;++i)for(let o=i+1;o<t.length;++o){const a=t[i].radius+t[o].radius;q(t[i],t[o])+1e-10<a&&s(t[o],t[i])}const e=new Map;for(let i=0;i<t.length;++i){const o=n(t[i]).parent.setid;e.has(o)||e.set(o,[]),e.get(o).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}function dt(t){const n=s=>{const e=t.reduce((o,a)=>Math.max(o,a[s]+a.radius),Number.NEGATIVE_INFINITY),i=t.reduce((o,a)=>Math.min(o,a[s]-a.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}};return{xRange:n("x"),yRange:n("y")}}function Dt(t,n,s){n==null&&(n=Math.PI/2);let e=Ft(t).map(u=>Object.assign({},u));const i=me(e);for(const u of i){pe(u,n,s);const r=dt(u);u.size=(r.xRange.max-r.xRange.min)*(r.yRange.max-r.yRange.min),u.bounds=r}i.sort((u,r)=>r.size-u.size),e=i[0];let o=e.bounds;const a=(o.xRange.max-o.xRange.min)/50;function c(u,r,y){if(!u)return;const d=u.bounds;let b,x;if(r)b=o.xRange.max-d.xRange.min+a;else{b=o.xRange.max-d.xRange.max;const M=(d.xRange.max-d.xRange.min)/2-(o.xRange.max-o.xRange.min)/2;M<0&&(b+=M)}if(y)x=o.yRange.max-d.yRange.min+a;else{x=o.yRange.max-d.yRange.max;const M=(d.yRange.max-d.yRange.min)/2-(o.yRange.max-o.yRange.min)/2;M<0&&(x+=M)}for(const M of u)M.x+=b,M.y+=x,e.push(M)}let h=1;for(;h<i.length;)c(i[h],!0,!1),c(i[h+1],!1,!0),c(i[h+2],!0,!0),h+=3,o=dt(e);return Ot(e)}function Nt(t,n,s,e,i){const o=Ft(t);n-=2*e,s-=2*e;const{xRange:a,yRange:c}=dt(o);if(a.max===a.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let h,u;if(i){const b=Math.sqrt(i/Math.PI)*2;h=n/b,u=s/b}else h=n/(a.max-a.min),u=s/(c.max-c.min);const r=Math.min(u,h),y=(n-(a.max-a.min)*r)/2,d=(s-(c.max-c.min)*r)/2;return Ot(o.map(b=>({radius:r*b.radius,x:e+y+(b.x-a.min)*r,y:e+d+(b.y-c.min)*r,setid:b.setid})))}function Ot(t){const n={};for(const s of t)n[s.setid]=s;return n}function Ft(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}function be(t={}){let n=!1,s=600,e=350,i=15,o=1e3,a=Math.PI/2,c=!0,h=null,u=!0,r=!0,y=null,d=null,b=!1,x=null,M=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,A={},T=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],S=0,g=function(p){if(p in A)return A[p];var f=A[p]=T[S];return S+=1,S>=T.length&&(S=0),f},m=At,v=tt;function l(p){let f=p.datum();const N=new Set;f.forEach(k=>{k.size==0&&k.sets.length==1&&N.add(k.sets[0])}),f=f.filter(k=>!k.sets.some(F=>N.has(F)));let I={},C={};if(f.length>0){let k=m(f,{lossFunction:v,distinct:b});c&&(k=Dt(k,a,d)),I=Nt(k,s,e,i,h),C=jt(I,f,M)}const U={};f.forEach(k=>{k.label&&(U[k.sets]=k.label)});function j(k){if(k.sets in U)return U[k.sets];if(k.sets.length==1)return""+k.sets[0]}p.selectAll("svg").data([I]).enter().append("svg");const E=p.select("svg");n?E.attr("viewBox",`0 0 ${s} ${e}`):E.attr("width",s).attr("height",e);const R={};let _=!1;E.selectAll(".venn-area path").each(function(k){const F=this.getAttribute("d");k.sets.length==1&&F&&!b&&(_=!0,R[k.sets[0]]=ke(F))});function P(k){return F=>{const H=k.sets.map(et=>{let Y=R[et],Z=I[et];return Y||(Y={x:s/2,y:e/2,radius:1}),Z||(Z={x:s/2,y:e/2,radius:1}),{x:Y.x*(1-F)+Z.x*F,y:Y.y*(1-F)+Z.y*F,radius:Y.radius*(1-F)+Z.radius*F}});return St(H,x)}}const V=E.selectAll(".venn-area").data(f,k=>k.sets),O=V.enter().append("g").attr("class",k=>`venn-area venn-${k.sets.length==1?"circle":"intersection"}${k.colour||k.color?" venn-coloured":""}`).attr("data-venn-sets",k=>k.sets.join("_")),B=O.append("path"),W=O.append("text").attr("class","label").text(k=>j(k)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);r&&(B.style("fill-opacity","0").filter(k=>k.sets.length==1).style("fill",k=>k.colour?k.colour:k.color?k.color:g(k.sets)).style("fill-opacity",".25"),W.style("fill",k=>k.colour||k.color?"#FFF":t.textFill?t.textFill:k.sets.length==1?g(k.sets):"#444"));function K(k){return typeof k.transition=="function"?k.transition("venn").duration(o):k}let z=p;_&&typeof z.transition=="function"?(z=K(p),z.selectAll("path").attrTween("d",P)):z.selectAll("path").attr("d",k=>St(k.sets.map(F=>I[F])),x);const L=z.selectAll("text").filter(k=>k.sets in C).text(k=>j(k)).attr("x",k=>Math.floor(C[k.sets].x)).attr("y",k=>Math.floor(C[k.sets].y));u&&(_?"on"in L?L.on("end",rt(I,j)):L.each("end",rt(I,j)):L.each(rt(I,j)));const D=K(V.exit()).remove();typeof V.transition=="function"&&D.selectAll("path").attrTween("d",P);const X=D.selectAll("text").attr("x",s/2).attr("y",e/2);return y!==null&&(W.style("font-size","0px"),L.style("font-size",y),X.style("font-size","0px")),{circles:I,textCentres:C,nodes:V,enter:O,update:z,exit:D}}return l.wrap=function(p){return arguments.length?(u=p,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(p){return arguments.length?(s=p,l):s},l.height=function(p){return arguments.length?(e=p,l):e},l.padding=function(p){return arguments.length?(i=p,l):i},l.distinct=function(p){return arguments.length?(b=p,l):b},l.colours=function(p){return arguments.length?(g=p,l):g},l.colors=function(p){return arguments.length?(g=p,l):g},l.fontSize=function(p){return arguments.length?(y=p,l):y},l.round=function(p){return arguments.length?(x=p,l):x},l.duration=function(p){return arguments.length?(o=p,l):o},l.layoutFunction=function(p){return arguments.length?(m=p,l):m},l.normalize=function(p){return arguments.length?(c=p,l):c},l.scaleToFit=function(p){return arguments.length?(h=p,l):h},l.styled=function(p){return arguments.length?(r=p,l):r},l.orientation=function(p){return arguments.length?(a=p,l):a},l.orientationOrder=function(p){return arguments.length?(d=p,l):d},l.lossFunction=function(p){return arguments.length?(v=p==="default"?tt:p==="logRatio"?Ct:p,l):v},l}function rt(t,n){return function(s){const e=this,i=t[s.sets[0]].radius||50,o=n(s)||"",a=o.split(/\s+/).reverse(),h=(o.length+a.length)/3;let u=a.pop(),r=[u],y=0;const d=1.1;e.textContent=null;const b=[];function x(g){const m=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return m.textContent=g,b.push(m),e.append(m),m}let M=x(u);for(;u=a.pop(),!!u;){r.push(u);const g=r.join(" ");M.textContent=g,g.length>h&&M.getComputedTextLength()>i&&(r.pop(),M.textContent=r.join(" "),r=[u],M=x(u),y++)}const A=.35-y*d/2,T=e.getAttribute("x"),S=e.getAttribute("y");b.forEach((g,m)=>{g.setAttribute("x",T),g.setAttribute("y",S),g.setAttribute("dy",`${A+m*d}em`)})}}function at(t,n,s){let e=n[0].radius-q(n[0],t);for(let i=1;i<n.length;++i){const o=n[i].radius-q(n[i],t);o<=e&&(e=o)}for(let i=0;i<s.length;++i){const o=q(s[i],t)-s[i].radius;o<=e&&(e=o)}return e}function Lt(t,n,s){const e=[];for(const r of t)e.push({x:r.x,y:r.y}),e.push({x:r.x+r.radius/2,y:r.y}),e.push({x:r.x-r.radius/2,y:r.y}),e.push({x:r.x,y:r.y+r.radius/2}),e.push({x:r.x,y:r.y-r.radius/2});let i=e[0],o=at(e[0],t,n);for(let r=1;r<e.length;++r){const y=at(e[r],t,n);y>=o&&(i=e[r],o=y)}const a=zt(r=>-1*at({x:r[0],y:r[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:a[0],y:a[1]};let h=!0;for(const r of t)if(q(c,r)>r.radius){h=!1;break}for(const r of n)if(q(c,r)<r.radius){h=!1;break}if(h)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};const u={};return st(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?Lt(t,[]):Et(u.arcs.map(r=>r.p1))}function ve(t){const n={},s=Object.keys(t);for(const e of s)n[e]=[];for(let e=0;e<s.length;e++){const i=s[e],o=t[i];for(let a=e+1;a<s.length;++a){const c=s[a],h=t[c],u=q(o,h);u+h.radius<=o.radius+1e-10?n[c].push(i):u+o.radius<=h.radius+1e-10&&n[i].push(c)}}return n}function jt(t,n,s){const e={},i=ve(t);for(let o=0;o<n.length;++o){const a=n[o].sets,c={},h={};for(let d=0;d<a.length;++d){c[a[d]]=!0;const b=i[a[d]];for(let x=0;x<b.length;++x)h[b[x]]=!0}const u=[],r=[];for(let d in t)d in c?u.push(t[d]):d in h||r.push(t[d]);const y=Lt(u,r,s);e[a]=y,y.disjoint&&n[o].size>0&&console.log("WARNING: area "+a+" not represented on screen")}return e}function Ie(t,n,s){const e=[];return e.push(`
|
|
1
|
+
import{aO as Gt,_ as w,s as Wt,g as Kt,t as Ht,q as Yt,a as Xt,b as Zt,K as wt,N as Jt,d as ot,av as Qt,ag as $t,ah as te,ai as ee,e as ne,A as se,H as ie,L as oe}from"./mermaid-O7DHMXV3-XxAJo8EK.js";import"./vendor-react-xmA_f8ig.js";import"./vendor-codemirror-CMHSJ_9p.js";import"./index-C514cLyb.js";const kt=(t,n)=>Gt(t,"a",-n),_t=1e-10;function st(t,n){const s=ae(t),e=s.filter(c=>re(c,t));let i=0,o=0;const a=[];if(e.length>1){const c=Et(e);for(let u=0;u<e.length;++u){const r=e[u];r.angle=Math.atan2(r.x-c.x,r.y-c.y)}e.sort((u,r)=>r.angle-u.angle);let h=e[e.length-1];for(let u=0;u<e.length;++u){const r=e[u];o+=(h.x+r.x)*(r.y-h.y);const y={x:(r.x+h.x)/2,y:(r.y+h.y)/2};let d=null;for(let b=0;b<r.parentIndex.length;++b)if(h.parentIndex.includes(r.parentIndex[b])){const x=t[r.parentIndex[b]],M=Math.atan2(r.x-x.x,r.y-x.y),A=Math.atan2(h.x-x.x,h.y-x.y);let T=A-M;T<0&&(T+=2*Math.PI);const S=A-T/2;let g=q(y,{x:x.x+x.radius*Math.sin(S),y:x.y+x.radius*Math.cos(S)});g>x.radius*2&&(g=x.radius*2),(d==null||d.width>g)&&(d={circle:x,width:g,p1:r,p2:h,large:g>x.radius,sweep:!0})}d!=null&&(a.push(d),i+=lt(d.circle.radius,d.width),h=r)}}else{let c=t[0];for(let u=1;u<t.length;++u)t[u].radius<c.radius&&(c=t[u]);let h=!1;for(let u=0;u<t.length;++u)if(q(t[u],c)>Math.abs(c.radius-t[u].radius)){h=!0;break}h?i=o=0:(i=c.radius*c.radius*Math.PI,a.push({circle:c,p1:{x:c.x,y:c.y+c.radius},p2:{x:c.x-_t,y:c.y+c.radius},width:c.radius*2,large:!0,sweep:!0}))}return o/=2,n&&(n.area=i+o,n.arcArea=i,n.polygonArea=o,n.arcs=a,n.innerPoints=e,n.intersectionPoints=s),i+o}function re(t,n){return n.every(s=>q(t,s)<s.radius+_t)}function ae(t){const n=[];for(let s=0;s<t.length;++s)for(let e=s+1;e<t.length;++e){const i=Tt(t[s],t[e]);for(const o of i)o.parentIndex=[s,e],n.push(o)}return n}function lt(t,n){return t*t*Math.acos(1-n/t)-(t-n)*Math.sqrt(n*(2*t-n))}function q(t,n){return Math.sqrt((t.x-n.x)*(t.x-n.x)+(t.y-n.y)*(t.y-n.y))}function xt(t,n,s){if(s>=t+n)return 0;if(s<=Math.abs(t-n))return Math.PI*Math.min(t,n)*Math.min(t,n);const e=t-(s*s-n*n+t*t)/(2*s),i=n-(s*s-t*t+n*n)/(2*s);return lt(t,e)+lt(n,i)}function Tt(t,n){const s=q(t,n),e=t.radius,i=n.radius;if(s>=e+i||s<=Math.abs(e-i))return[];const o=(e*e-i*i+s*s)/(2*s),a=Math.sqrt(e*e-o*o),c=t.x+o*(n.x-t.x)/s,h=t.y+o*(n.y-t.y)/s,u=-(n.y-t.y)*(a/s),r=-(n.x-t.x)*(a/s);return[{x:c+u,y:h-r},{x:c-u,y:h+r}]}function Et(t){const n={x:0,y:0};for(const s of t)n.x+=s.x,n.y+=s.y;return n.x/=t.length,n.y/=t.length,n}function le(t,n,s,e){e=e||{};const i=e.maxIterations||100,o=e.tolerance||1e-10,a=t(n),c=t(s);let h=s-n;if(a*c>0)throw"Initial bisect points must have opposite signs";if(a===0)return n;if(c===0)return s;for(let u=0;u<i;++u){h/=2;const r=n+h,y=t(r);if(y*a>=0&&(n=r),Math.abs(h)<o||y===0)return r}return n+h}function ct(t){const n=new Array(t);for(let s=0;s<t;++s)n[s]=0;return n}function Mt(t,n){return ct(t).map(()=>ct(n))}function $(t,n){let s=0;for(let e=0;e<t.length;++e)s+=t[e]*n[e];return s}function ut(t){return Math.sqrt($(t,t))}function ft(t,n,s){for(let e=0;e<n.length;++e)t[e]=n[e]*s}function J(t,n,s,e,i){for(let o=0;o<t.length;++o)t[o]=n*s[o]+e*i[o]}function zt(t,n,s){s=s||{};const e=s.maxIterations||n.length*200,i=s.nonZeroDelta||1.05,o=s.zeroDelta||.001,a=s.minErrorDelta||1e-6,c=s.minErrorDelta||1e-5,h=s.rho!==void 0?s.rho:1,u=s.chi!==void 0?s.chi:2,r=s.psi!==void 0?s.psi:-.5,y=s.sigma!==void 0?s.sigma:.5;let d;const b=n.length,x=new Array(b+1);x[0]=n,x[0].fx=t(n),x[0].id=0;for(let v=0;v<b;++v){const l=n.slice();l[v]=l[v]?l[v]*i:o,x[v+1]=l,x[v+1].fx=t(l),x[v+1].id=v+1}function M(v){for(let l=0;l<v.length;l++)x[b][l]=v[l];x[b].fx=v.fx}const A=(v,l)=>v.fx-l.fx,T=n.slice(),S=n.slice(),g=n.slice(),m=n.slice();for(let v=0;v<e;++v){if(x.sort(A),s.history){const p=x.map(f=>{const N=f.slice();return N.fx=f.fx,N.id=f.id,N});p.sort((f,N)=>f.id-N.id),s.history.push({x:x[0].slice(),fx:x[0].fx,simplex:p})}d=0;for(let p=0;p<b;++p)d=Math.max(d,Math.abs(x[0][p]-x[1][p]));if(Math.abs(x[0].fx-x[b].fx)<a&&d<c)break;for(let p=0;p<b;++p){T[p]=0;for(let f=0;f<b;++f)T[p]+=x[f][p];T[p]/=b}const l=x[b];if(J(S,1+h,T,-h,l),S.fx=t(S),S.fx<x[0].fx)J(m,1+u,T,-u,l),m.fx=t(m),m.fx<S.fx?M(m):M(S);else if(S.fx>=x[b-1].fx){let p=!1;if(S.fx>l.fx?(J(g,1+r,T,-r,l),g.fx=t(g),g.fx<l.fx?M(g):p=!0):(J(g,1-r*h,T,r*h,l),g.fx=t(g),g.fx<S.fx?M(g):p=!0),p){if(y>=1)break;for(let f=1;f<x.length;++f)J(x[f],1-y,x[0],y,x[f]),x[f].fx=t(x[f])}}else M(S)}return x.sort(A),{fx:x[0].fx,x:x[0]}}function ce(t,n,s,e,i,o,a){const c=s.fx,h=$(s.fxprime,n);let u=c,r=c,y=h,d=0;i=i||1,o=o||1e-6,a=a||.1;function b(x,M,A){for(let T=0;T<16;++T)if(i=(x+M)/2,J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=$(e.fxprime,n),u>c+o*i*h||u>=A)M=i;else{if(Math.abs(y)<=-a*h)return i;y*(M-x)>=0&&(M=x),x=i,A=u}return 0}for(let x=0;x<10;++x){if(J(e.x,1,s.x,i,n),u=e.fx=t(e.x,e.fxprime),y=$(e.fxprime,n),u>c+o*i*h||x&&u>=r)return b(d,i,r);if(Math.abs(y)<=-a*h)return i;if(y>=0)return b(i,d,u);r=u,d=i,i*=2}return i}function ue(t,n,s){let e={x:n.slice(),fx:0,fxprime:n.slice()},i={x:n.slice(),fx:0,fxprime:n.slice()};const o=n.slice();let a,c,h=1,u;s=s||{},u=s.maxIterations||n.length*20,e.fx=t(e.x,e.fxprime),a=e.fxprime.slice(),ft(a,e.fxprime,-1);for(let r=0;r<u;++r){if(h=ce(t,a,e,i,h),s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),!h)ft(a,e.fxprime,-1);else{J(o,1,i.fxprime,-1,e.fxprime);const y=$(e.fxprime,e.fxprime),d=Math.max(0,$(o,i.fxprime)/y);J(a,d,a,-1,i.fxprime),c=e,e=i,i=c}if(ut(e.fxprime)<=1e-5)break}return s.history&&s.history.push({x:e.x.slice(),fx:e.fx,fxprime:e.fxprime.slice(),alpha:h}),e}function At(t,n={}){n.maxIterations=n.maxIterations||500;const s=n.initialLayout||ge,e=n.lossFunction||tt,i=fe(t,n),o=s(i,n),a=Object.keys(o),c=[];for(const r of a)c.push(o[r].x),c.push(o[r].y);const u=zt(r=>{const y={};for(let d=0;d<a.length;++d){const b=a[d];y[b]={x:r[2*d],y:r[2*d+1],radius:o[b].radius}}return e(y,i)},c,n).x;for(let r=0;r<a.length;++r){const y=a[r];o[y].x=u[2*r],o[y].y=u[2*r+1]}return o}const Rt=1e-10;function ht(t,n,s){return Math.min(t,n)*Math.min(t,n)*Math.PI<=s+Rt?Math.abs(t-n):le(e=>xt(t,n,e)-s,0,t+n)}function fe(t,n={}){const s=n.distinct,e=t.map(c=>Object.assign({},c));function i(c){return c.join(";")}if(s){const c=new Map;for(const h of e)for(let u=0;u<h.sets.length;u++){const r=String(h.sets[u]);c.set(r,h.size+(c.get(r)||0));for(let y=u+1;y<h.sets.length;y++){const d=String(h.sets[y]),b=`${r};${d}`,x=`${d};${r}`;c.set(b,h.size+(c.get(b)||0)),c.set(x,h.size+(c.get(x)||0))}}for(const h of e)h.sets.length<3&&(h.size=c.get(i(h.sets)))}const o=[],a=new Set;for(const c of e)if(c.sets.length===1)o.push(c.sets[0]);else if(c.sets.length===2){const h=c.sets[0],u=c.sets[1];a.add(i(c.sets)),a.add(i([u,h]))}o.sort((c,h)=>c===h?0:c<h?-1:1);for(let c=0;c<o.length;++c){const h=o[c];for(let u=c+1;u<o.length;++u){const r=o[u];a.has(i([h,r]))||e.push({sets:[h,r],size:0})}}return e}function he(t,n,s){const e=Mt(n.length,n.length),i=Mt(n.length,n.length);return t.filter(o=>o.sets.length===2).forEach(o=>{const a=s[o.sets[0]],c=s[o.sets[1]],h=Math.sqrt(n[a].size/Math.PI),u=Math.sqrt(n[c].size/Math.PI),r=ht(h,u,o.size);e[a][c]=e[c][a]=r;let y=0;o.size+1e-10>=Math.min(n[a].size,n[c].size)?y=1:o.size<=1e-10&&(y=-1),i[a][c]=i[c][a]=y}),{distances:e,constraints:i}}function de(t,n,s,e){for(let o=0;o<n.length;++o)n[o]=0;let i=0;for(let o=0;o<s.length;++o){const a=t[2*o],c=t[2*o+1];for(let h=o+1;h<s.length;++h){const u=t[2*h],r=t[2*h+1],y=s[o][h],d=e[o][h],b=(u-a)*(u-a)+(r-c)*(r-c),x=Math.sqrt(b),M=b-y*y;d>0&&x<=y||d<0&&x>=y||(i+=2*M*M,n[2*o]+=4*M*(a-u),n[2*o+1]+=4*M*(c-r),n[2*h]+=4*M*(u-a),n[2*h+1]+=4*M*(r-c))}}return i}function ge(t,n={}){let s=ye(t,n);const e=n.lossFunction||tt;if(t.length>=8){const i=xe(t,n),o=e(i,t),a=e(s,t);o+1e-8<a&&(s=i)}return s}function xe(t,n={}){const s=n.restarts||10,e=[],i={};for(const d of t)d.sets.length===1&&(i[d.sets[0]]=e.length,e.push(d));let{distances:o,constraints:a}=he(t,e,i);const c=ut(o.map(ut))/o.length;o=o.map(d=>d.map(b=>b/c));const h=(d,b)=>de(d,b,o,a);let u=null;for(let d=0;d<s;++d){const b=ct(o.length*2).map(Math.random),x=ue(h,b,n);(!u||x.fx<u.fx)&&(u=x)}const r=u.x,y={};for(let d=0;d<e.length;++d){const b=e[d];y[b.sets[0]]={x:r[2*d]*c,y:r[2*d+1]*c,radius:Math.sqrt(b.size/Math.PI)}}if(n.history)for(const d of n.history)ft(d.x,c);return y}function ye(t,n){const s=n&&n.lossFunction?n.lossFunction:tt,e={},i={};for(const y of t)if(y.sets.length===1){const d=y.sets[0];e[d]={x:1e10,y:1e10,rowid:e.length,size:y.size,radius:Math.sqrt(y.size/Math.PI)},i[d]=[]}t=t.filter(y=>y.sets.length===2);for(const y of t){let d=y.weight!=null?y.weight:1;const b=y.sets[0],x=y.sets[1];y.size+Rt>=Math.min(e[b].size,e[x].size)&&(d=0),i[b].push({set:x,size:y.size,weight:d}),i[x].push({set:b,size:y.size,weight:d})}const o=[];Object.keys(i).forEach(y=>{let d=0;for(let b=0;b<i[y].length;++b)d+=i[y][b].size*i[y][b].weight;o.push({set:y,size:d})});function a(y,d){return d.size-y.size}o.sort(a);const c={};function h(y){return y.set in c}function u(y,d){e[d].x=y.x,e[d].y=y.y,c[d]=!0}u({x:0,y:0},o[0].set);for(let y=1;y<o.length;++y){const d=o[y].set,b=i[d].filter(h),x=e[d];if(b.sort(a),b.length===0)throw"ERROR: missing pairwise overlap information";const M=[];for(var r=0;r<b.length;++r){const S=e[b[r].set],g=ht(x.radius,S.radius,b[r].size);M.push({x:S.x+g,y:S.y}),M.push({x:S.x-g,y:S.y}),M.push({y:S.y+g,x:S.x}),M.push({y:S.y-g,x:S.x});for(let m=r+1;m<b.length;++m){const v=e[b[m].set],l=ht(x.radius,v.radius,b[m].size),p=Tt({x:S.x,y:S.y,radius:g},{x:v.x,y:v.y,radius:l});M.push(...p)}}let A=1e50,T=M[0];for(const S of M){e[d].x=S.x,e[d].y=S.y;const g=s(e,t);g<A&&(A=g,T=S)}u(T,d)}return e}function tt(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const a=t[e.sets[0]],c=t[e.sets[1]];i=xt(a.radius,c.radius,q(a,c))}else i=st(e.sets.map(a=>t[a]));const o=e.weight!=null?e.weight:1;s+=o*(i-e.size)*(i-e.size)}return s}function Ct(t,n){let s=0;for(const e of n){if(e.sets.length===1)continue;let i;if(e.sets.length===2){const c=t[e.sets[0]],h=t[e.sets[1]];i=xt(c.radius,h.radius,q(c,h))}else i=st(e.sets.map(c=>t[c]));const o=e.weight!=null?e.weight:1,a=Math.log((i+1)/(e.size+1));s+=o*a*a}return s}function pe(t,n,s){if(s==null?t.sort((i,o)=>o.radius-i.radius):t.sort(s),t.length>0){const i=t[0].x,o=t[0].y;for(const a of t)a.x-=i,a.y-=o}if(t.length===2&&q(t[0],t[1])<Math.abs(t[1].radius-t[0].radius)&&(t[1].x=t[0].x+t[0].radius-t[1].radius-1e-10,t[1].y=t[0].y),t.length>1){const i=Math.atan2(t[1].x,t[1].y)-n,o=Math.cos(i),a=Math.sin(i);for(const c of t){const h=c.x,u=c.y;c.x=o*h-a*u,c.y=a*h+o*u}}if(t.length>2){let i=Math.atan2(t[2].x,t[2].y)-n;for(;i<0;)i+=2*Math.PI;for(;i>2*Math.PI;)i-=2*Math.PI;if(i>Math.PI){const o=t[1].y/(1e-10+t[1].x);for(const a of t){var e=(a.x+o*a.y)/(1+o*o);a.x=2*e-a.x,a.y=2*e*o-a.y}}}}function me(t){t.forEach(i=>{i.parent=i});function n(i){return i.parent!==i&&(i.parent=n(i.parent)),i.parent}function s(i,o){const a=n(i),c=n(o);a.parent=c}for(let i=0;i<t.length;++i)for(let o=i+1;o<t.length;++o){const a=t[i].radius+t[o].radius;q(t[i],t[o])+1e-10<a&&s(t[o],t[i])}const e=new Map;for(let i=0;i<t.length;++i){const o=n(t[i]).parent.setid;e.has(o)||e.set(o,[]),e.get(o).push(t[i])}return t.forEach(i=>{delete i.parent}),Array.from(e.values())}function dt(t){const n=s=>{const e=t.reduce((o,a)=>Math.max(o,a[s]+a.radius),Number.NEGATIVE_INFINITY),i=t.reduce((o,a)=>Math.min(o,a[s]-a.radius),Number.POSITIVE_INFINITY);return{max:e,min:i}};return{xRange:n("x"),yRange:n("y")}}function Dt(t,n,s){n==null&&(n=Math.PI/2);let e=Ft(t).map(u=>Object.assign({},u));const i=me(e);for(const u of i){pe(u,n,s);const r=dt(u);u.size=(r.xRange.max-r.xRange.min)*(r.yRange.max-r.yRange.min),u.bounds=r}i.sort((u,r)=>r.size-u.size),e=i[0];let o=e.bounds;const a=(o.xRange.max-o.xRange.min)/50;function c(u,r,y){if(!u)return;const d=u.bounds;let b,x;if(r)b=o.xRange.max-d.xRange.min+a;else{b=o.xRange.max-d.xRange.max;const M=(d.xRange.max-d.xRange.min)/2-(o.xRange.max-o.xRange.min)/2;M<0&&(b+=M)}if(y)x=o.yRange.max-d.yRange.min+a;else{x=o.yRange.max-d.yRange.max;const M=(d.yRange.max-d.yRange.min)/2-(o.yRange.max-o.yRange.min)/2;M<0&&(x+=M)}for(const M of u)M.x+=b,M.y+=x,e.push(M)}let h=1;for(;h<i.length;)c(i[h],!0,!1),c(i[h+1],!1,!0),c(i[h+2],!0,!0),h+=3,o=dt(e);return Ot(e)}function Nt(t,n,s,e,i){const o=Ft(t);n-=2*e,s-=2*e;const{xRange:a,yRange:c}=dt(o);if(a.max===a.min||c.max===c.min)return console.log("not scaling solution: zero size detected"),t;let h,u;if(i){const b=Math.sqrt(i/Math.PI)*2;h=n/b,u=s/b}else h=n/(a.max-a.min),u=s/(c.max-c.min);const r=Math.min(u,h),y=(n-(a.max-a.min)*r)/2,d=(s-(c.max-c.min)*r)/2;return Ot(o.map(b=>({radius:r*b.radius,x:e+y+(b.x-a.min)*r,y:e+d+(b.y-c.min)*r,setid:b.setid})))}function Ot(t){const n={};for(const s of t)n[s.setid]=s;return n}function Ft(t){return Object.keys(t).map(s=>Object.assign(t[s],{setid:s}))}function be(t={}){let n=!1,s=600,e=350,i=15,o=1e3,a=Math.PI/2,c=!0,h=null,u=!0,r=!0,y=null,d=null,b=!1,x=null,M=t&&t.symmetricalTextCentre?t.symmetricalTextCentre:!1,A={},T=t&&t.colourScheme?t.colourScheme:t&&t.colorScheme?t.colorScheme:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],S=0,g=function(p){if(p in A)return A[p];var f=A[p]=T[S];return S+=1,S>=T.length&&(S=0),f},m=At,v=tt;function l(p){let f=p.datum();const N=new Set;f.forEach(k=>{k.size==0&&k.sets.length==1&&N.add(k.sets[0])}),f=f.filter(k=>!k.sets.some(F=>N.has(F)));let I={},C={};if(f.length>0){let k=m(f,{lossFunction:v,distinct:b});c&&(k=Dt(k,a,d)),I=Nt(k,s,e,i,h),C=jt(I,f,M)}const U={};f.forEach(k=>{k.label&&(U[k.sets]=k.label)});function j(k){if(k.sets in U)return U[k.sets];if(k.sets.length==1)return""+k.sets[0]}p.selectAll("svg").data([I]).enter().append("svg");const E=p.select("svg");n?E.attr("viewBox",`0 0 ${s} ${e}`):E.attr("width",s).attr("height",e);const R={};let _=!1;E.selectAll(".venn-area path").each(function(k){const F=this.getAttribute("d");k.sets.length==1&&F&&!b&&(_=!0,R[k.sets[0]]=ke(F))});function P(k){return F=>{const H=k.sets.map(et=>{let Y=R[et],Z=I[et];return Y||(Y={x:s/2,y:e/2,radius:1}),Z||(Z={x:s/2,y:e/2,radius:1}),{x:Y.x*(1-F)+Z.x*F,y:Y.y*(1-F)+Z.y*F,radius:Y.radius*(1-F)+Z.radius*F}});return St(H,x)}}const V=E.selectAll(".venn-area").data(f,k=>k.sets),O=V.enter().append("g").attr("class",k=>`venn-area venn-${k.sets.length==1?"circle":"intersection"}${k.colour||k.color?" venn-coloured":""}`).attr("data-venn-sets",k=>k.sets.join("_")),B=O.append("path"),W=O.append("text").attr("class","label").text(k=>j(k)).attr("text-anchor","middle").attr("dy",".35em").attr("x",s/2).attr("y",e/2);r&&(B.style("fill-opacity","0").filter(k=>k.sets.length==1).style("fill",k=>k.colour?k.colour:k.color?k.color:g(k.sets)).style("fill-opacity",".25"),W.style("fill",k=>k.colour||k.color?"#FFF":t.textFill?t.textFill:k.sets.length==1?g(k.sets):"#444"));function K(k){return typeof k.transition=="function"?k.transition("venn").duration(o):k}let z=p;_&&typeof z.transition=="function"?(z=K(p),z.selectAll("path").attrTween("d",P)):z.selectAll("path").attr("d",k=>St(k.sets.map(F=>I[F])),x);const L=z.selectAll("text").filter(k=>k.sets in C).text(k=>j(k)).attr("x",k=>Math.floor(C[k.sets].x)).attr("y",k=>Math.floor(C[k.sets].y));u&&(_?"on"in L?L.on("end",rt(I,j)):L.each("end",rt(I,j)):L.each(rt(I,j)));const D=K(V.exit()).remove();typeof V.transition=="function"&&D.selectAll("path").attrTween("d",P);const X=D.selectAll("text").attr("x",s/2).attr("y",e/2);return y!==null&&(W.style("font-size","0px"),L.style("font-size",y),X.style("font-size","0px")),{circles:I,textCentres:C,nodes:V,enter:O,update:z,exit:D}}return l.wrap=function(p){return arguments.length?(u=p,l):u},l.useViewBox=function(){return n=!0,l},l.width=function(p){return arguments.length?(s=p,l):s},l.height=function(p){return arguments.length?(e=p,l):e},l.padding=function(p){return arguments.length?(i=p,l):i},l.distinct=function(p){return arguments.length?(b=p,l):b},l.colours=function(p){return arguments.length?(g=p,l):g},l.colors=function(p){return arguments.length?(g=p,l):g},l.fontSize=function(p){return arguments.length?(y=p,l):y},l.round=function(p){return arguments.length?(x=p,l):x},l.duration=function(p){return arguments.length?(o=p,l):o},l.layoutFunction=function(p){return arguments.length?(m=p,l):m},l.normalize=function(p){return arguments.length?(c=p,l):c},l.scaleToFit=function(p){return arguments.length?(h=p,l):h},l.styled=function(p){return arguments.length?(r=p,l):r},l.orientation=function(p){return arguments.length?(a=p,l):a},l.orientationOrder=function(p){return arguments.length?(d=p,l):d},l.lossFunction=function(p){return arguments.length?(v=p==="default"?tt:p==="logRatio"?Ct:p,l):v},l}function rt(t,n){return function(s){const e=this,i=t[s.sets[0]].radius||50,o=n(s)||"",a=o.split(/\s+/).reverse(),h=(o.length+a.length)/3;let u=a.pop(),r=[u],y=0;const d=1.1;e.textContent=null;const b=[];function x(g){const m=e.ownerDocument.createElementNS(e.namespaceURI,"tspan");return m.textContent=g,b.push(m),e.append(m),m}let M=x(u);for(;u=a.pop(),!!u;){r.push(u);const g=r.join(" ");M.textContent=g,g.length>h&&M.getComputedTextLength()>i&&(r.pop(),M.textContent=r.join(" "),r=[u],M=x(u),y++)}const A=.35-y*d/2,T=e.getAttribute("x"),S=e.getAttribute("y");b.forEach((g,m)=>{g.setAttribute("x",T),g.setAttribute("y",S),g.setAttribute("dy",`${A+m*d}em`)})}}function at(t,n,s){let e=n[0].radius-q(n[0],t);for(let i=1;i<n.length;++i){const o=n[i].radius-q(n[i],t);o<=e&&(e=o)}for(let i=0;i<s.length;++i){const o=q(s[i],t)-s[i].radius;o<=e&&(e=o)}return e}function Lt(t,n,s){const e=[];for(const r of t)e.push({x:r.x,y:r.y}),e.push({x:r.x+r.radius/2,y:r.y}),e.push({x:r.x-r.radius/2,y:r.y}),e.push({x:r.x,y:r.y+r.radius/2}),e.push({x:r.x,y:r.y-r.radius/2});let i=e[0],o=at(e[0],t,n);for(let r=1;r<e.length;++r){const y=at(e[r],t,n);y>=o&&(i=e[r],o=y)}const a=zt(r=>-1*at({x:r[0],y:r[1]},t,n),[i.x,i.y],{maxIterations:500,minErrorDelta:1e-10}).x,c={x:s?0:a[0],y:a[1]};let h=!0;for(const r of t)if(q(c,r)>r.radius){h=!1;break}for(const r of n)if(q(c,r)<r.radius){h=!1;break}if(h)return c;if(t.length==1)return{x:t[0].x,y:t[0].y};const u={};return st(t,u),u.arcs.length===0?{x:0,y:-1e3,disjoint:!0}:u.arcs.length==1?{x:u.arcs[0].circle.x,y:u.arcs[0].circle.y}:n.length?Lt(t,[]):Et(u.arcs.map(r=>r.p1))}function ve(t){const n={},s=Object.keys(t);for(const e of s)n[e]=[];for(let e=0;e<s.length;e++){const i=s[e],o=t[i];for(let a=e+1;a<s.length;++a){const c=s[a],h=t[c],u=q(o,h);u+h.radius<=o.radius+1e-10?n[c].push(i):u+o.radius<=h.radius+1e-10&&n[i].push(c)}}return n}function jt(t,n,s){const e={},i=ve(t);for(let o=0;o<n.length;++o){const a=n[o].sets,c={},h={};for(let d=0;d<a.length;++d){c[a[d]]=!0;const b=i[a[d]];for(let x=0;x<b.length;++x)h[b[x]]=!0}const u=[],r=[];for(let d in t)d in c?u.push(t[d]):d in h||r.push(t[d]);const y=Lt(u,r,s);e[a]=y,y.disjoint&&n[o].size>0&&console.log("WARNING: area "+a+" not represented on screen")}return e}function Ie(t,n,s){const e=[];return e.push(`
|
|
2
2
|
M`,t,n),e.push(`
|
|
3
3
|
m`,-s,0),e.push(`
|
|
4
4
|
a`,s,s,0,1,0,s*2,0),e.push(`
|
package/dist/assets/{xychartDiagram-JWTSCODW-eRk-39YO.js → xychartDiagram-JWTSCODW-Cfp1I4_U.js}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{_ as a,s as gi,g as xi,t as Xt,q as di,a as fi,b as pi,l as Nt,N as mi,e as yi,A as bi,K as St,H as Yt,L as Ai,a4 as wi,i as Ci,aN as Si,ac as Wt}from"./mermaid-O7DHMXV3-
|
|
1
|
+
import{_ as a,s as gi,g as xi,t as Xt,q as di,a as fi,b as pi,l as Nt,N as mi,e as yi,A as bi,K as St,H as Yt,L as Ai,a4 as wi,i as Ci,aN as Si,ac as Wt}from"./mermaid-O7DHMXV3-XxAJo8EK.js";import{i as _i}from"./init-Gi6I4Gst.js";import{o as ki}from"./ordinal-Cboi1Yqb.js";import{l as zt}from"./linear-DE7bISck.js";import"./vendor-react-xmA_f8ig.js";import"./vendor-codemirror-CMHSJ_9p.js";import"./index-C514cLyb.js";import"./defaultLocale-DX6XiGOO.js";function Ri(e,t,i){e=+e,t=+t,i=(n=arguments.length)<2?(t=e,e=0,1):n<3?1:+i;for(var s=-1,n=Math.max(0,Math.ceil((t-e)/i))|0,o=new Array(n);++s<n;)o[s]=e+s*i;return o}function yt(){var e=ki().unknown(void 0),t=e.domain,i=e.range,s=0,n=1,o,g,m=!1,p=0,k=0,v=.5;delete e.unknown;function C(){var b=t().length,E=n<s,D=E?n:s,P=E?s:n;o=(P-D)/Math.max(1,b-p+k*2),m&&(o=Math.floor(o)),D+=(P-D-o*(b-p))*v,g=o*(1-p),m&&(D=Math.round(D),g=Math.round(g));var I=Ri(b).map(function(y){return D+o*y});return i(E?I.reverse():I)}return e.domain=function(b){return arguments.length?(t(b),C()):t()},e.range=function(b){return arguments.length?([s,n]=b,s=+s,n=+n,C()):[s,n]},e.rangeRound=function(b){return[s,n]=b,s=+s,n=+n,m=!0,C()},e.bandwidth=function(){return g},e.step=function(){return o},e.round=function(b){return arguments.length?(m=!!b,C()):m},e.padding=function(b){return arguments.length?(p=Math.min(1,k=+b),C()):p},e.paddingInner=function(b){return arguments.length?(p=Math.min(1,b),C()):p},e.paddingOuter=function(b){return arguments.length?(k=+b,C()):k},e.align=function(b){return arguments.length?(v=Math.max(0,Math.min(1,b)),C()):v},e.copy=function(){return yt(t(),[s,n]).round(m).paddingInner(p).paddingOuter(k).align(v)},_i.apply(C(),arguments)}var bt=function(){var e=a(function(O,h,u,x){for(u=u||{},x=O.length;x--;u[O[x]]=h);return u},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],s=[1,3],n=[1,5],o=[1,6],g=[1,7],m=[1,5,10,12,14,16,18,19,21,23,34,35,36],p=[1,25],k=[1,26],v=[1,28],C=[1,29],b=[1,30],E=[1,31],D=[1,32],P=[1,33],I=[1,34],y=[1,35],_=[1,36],c=[1,37],W=[1,43],z=[1,42],U=[1,47],X=[1,50],l=[1,10,12,14,16,18,19,21,23,34,35,36],L=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],S=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],R=[1,64],$={trace:a(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:a(function(h,u,x,d,w,r,at){var f=r.length-1;switch(w){case 5:d.setOrientation(r[f]);break;case 9:d.setDiagramTitle(r[f].text.trim());break;case 12:d.setLineData({text:"",type:"text"},r[f]);break;case 13:d.setLineData(r[f-1],r[f]);break;case 14:d.setBarData({text:"",type:"text"},r[f]);break;case 15:d.setBarData(r[f-1],r[f]);break;case 16:this.$=r[f].trim(),d.setAccTitle(this.$);break;case 17:case 18:this.$=r[f].trim(),d.setAccDescription(this.$);break;case 19:this.$=r[f-1];break;case 20:this.$=[Number(r[f-2]),...r[f]];break;case 21:this.$=[Number(r[f])];break;case 22:d.setXAxisTitle(r[f]);break;case 23:d.setXAxisTitle(r[f-1]);break;case 24:d.setXAxisTitle({type:"text",text:""});break;case 25:d.setXAxisBand(r[f]);break;case 26:d.setXAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 27:this.$=r[f-1];break;case 28:this.$=[r[f-2],...r[f]];break;case 29:this.$=[r[f]];break;case 30:d.setYAxisTitle(r[f]);break;case 31:d.setYAxisTitle(r[f-1]);break;case 32:d.setYAxisTitle({type:"text",text:""});break;case 33:d.setYAxisRangeData(Number(r[f-2]),Number(r[f]));break;case 37:this.$={text:r[f],type:"text"};break;case 38:this.$={text:r[f],type:"text"};break;case 39:this.$={text:r[f],type:"markdown"};break;case 40:this.$=r[f];break;case 41:this.$=r[f-1]+""+r[f];break}},"anonymous"),table:[e(t,i,{3:1,4:2,7:4,5:s,34:n,35:o,36:g}),{1:[3]},e(t,i,{4:2,7:4,3:8,5:s,34:n,35:o,36:g}),e(t,i,{4:2,7:4,6:9,3:10,5:s,8:[1,11],34:n,35:o,36:g}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},e(m,[2,34]),e(m,[2,35]),e(m,[2,36]),{1:[2,1]},e(t,i,{4:2,7:4,3:21,5:s,34:n,35:o,36:g}),{1:[2,3]},e(m,[2,5]),e(t,[2,7],{4:22,34:n,35:o,36:g}),{11:23,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:39,13:38,24:W,27:z,29:40,30:41,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:45,15:44,27:U,33:46,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:49,17:48,24:X,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{11:52,17:51,24:X,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},{20:[1,53]},{22:[1,54]},e(l,[2,18]),{1:[2,2]},e(l,[2,8]),e(l,[2,9]),e(L,[2,37],{40:55,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c}),e(L,[2,38]),e(L,[2,39]),e(S,[2,40]),e(S,[2,42]),e(S,[2,43]),e(S,[2,44]),e(S,[2,45]),e(S,[2,46]),e(S,[2,47]),e(S,[2,48]),e(S,[2,49]),e(S,[2,50]),e(S,[2,51]),e(l,[2,10]),e(l,[2,22],{30:41,29:56,24:W,27:z}),e(l,[2,24]),e(l,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},e(l,[2,11]),e(l,[2,30],{33:60,27:U}),e(l,[2,32]),{31:[1,61]},e(l,[2,12]),{17:62,24:X},{25:63,27:R},e(l,[2,14]),{17:65,24:X},e(l,[2,16]),e(l,[2,17]),e(S,[2,41]),e(l,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},e(l,[2,31]),{27:[1,69]},e(l,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},e(l,[2,15]),e(l,[2,26]),e(l,[2,27]),{11:59,32:72,37:24,38:p,39:k,40:27,41:v,42:C,43:b,44:E,45:D,46:P,47:I,48:y,49:_,50:c},e(l,[2,33]),e(l,[2,19]),{25:73,27:R},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:a(function(h,u){if(u.recoverable)this.trace(h);else{var x=new Error(h);throw x.hash=u,x}},"parseError"),parse:a(function(h){var u=this,x=[0],d=[],w=[null],r=[],at=this.table,f="",lt=0,It=0,hi=2,Mt=1,li=r.slice.call(arguments,1),T=Object.create(this.lexer),Y={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(Y.yy[dt]=this.yy[dt]);T.setInput(h,Y.yy),Y.yy.lexer=T,Y.yy.parser=this,typeof T.yylloc>"u"&&(T.yylloc={});var ft=T.yylloc;r.push(ft);var ci=T.options&&T.options.ranges;typeof Y.yy.parseError=="function"?this.parseError=Y.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ui(V){x.length=x.length-2*V,w.length=w.length-V,r.length=r.length-V}a(ui,"popStack");function Vt(){var V;return V=d.pop()||T.lex()||Mt,typeof V!="number"&&(V instanceof Array&&(d=V,V=d.pop()),V=u.symbols_[V]||V),V}a(Vt,"lex");for(var M,H,B,pt,q={},ct,F,Bt,ut;;){if(H=x[x.length-1],this.defaultActions[H]?B=this.defaultActions[H]:((M===null||typeof M>"u")&&(M=Vt()),B=at[H]&&at[H][M]),typeof B>"u"||!B.length||!B[0]){var mt="";ut=[];for(ct in at[H])this.terminals_[ct]&&ct>hi&&ut.push("'"+this.terminals_[ct]+"'");T.showPosition?mt="Parse error on line "+(lt+1)+`:
|
|
2
2
|
`+T.showPosition()+`
|
|
3
3
|
Expecting `+ut.join(", ")+", got '"+(this.terminals_[M]||M)+"'":mt="Parse error on line "+(lt+1)+": Unexpected "+(M==Mt?"end of input":"'"+(this.terminals_[M]||M)+"'"),this.parseError(mt,{text:T.match,token:this.terminals_[M]||M,line:T.yylineno,loc:ft,expected:ut})}if(B[0]instanceof Array&&B.length>1)throw new Error("Parse Error: multiple actions possible at state: "+H+", token: "+M);switch(B[0]){case 1:x.push(M),w.push(T.yytext),r.push(T.yylloc),x.push(B[1]),M=null,It=T.yyleng,f=T.yytext,lt=T.yylineno,ft=T.yylloc;break;case 2:if(F=this.productions_[B[1]][1],q.$=w[w.length-F],q._$={first_line:r[r.length-(F||1)].first_line,last_line:r[r.length-1].last_line,first_column:r[r.length-(F||1)].first_column,last_column:r[r.length-1].last_column},ci&&(q._$.range=[r[r.length-(F||1)].range[0],r[r.length-1].range[1]]),pt=this.performAction.apply(q,[f,It,lt,Y.yy,B[1],w,r].concat(li)),typeof pt<"u")return pt;F&&(x=x.slice(0,-1*F*2),w=w.slice(0,-1*F),r=r.slice(0,-1*F)),x.push(this.productions_[B[1]][0]),w.push(q.$),r.push(q._$),Bt=at[x[x.length-2]][x[x.length-1]],x.push(Bt);break;case 3:return!0}}return!0},"parse")},Et=function(){var O={EOF:1,parseError:a(function(u,x){if(this.yy.parser)this.yy.parser.parseError(u,x);else throw new Error(u)},"parseError"),setInput:a(function(h,u){return this.yy=u||this.yy||{},this._input=h,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:a(function(){var h=this._input[0];this.yytext+=h,this.yyleng++,this.offset++,this.match+=h,this.matched+=h;var u=h.match(/(?:\r\n?|\n).*/g);return u?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),h},"input"),unput:a(function(h){var u=h.length,x=h.split(/(?:\r\n?|\n)/g);this._input=h+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-u),this.offset-=u;var d=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),x.length-1&&(this.yylineno-=x.length-1);var w=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:x?(x.length===d.length?this.yylloc.first_column:0)+d[d.length-x.length].length-x[0].length:this.yylloc.first_column-u},this.options.ranges&&(this.yylloc.range=[w[0],w[0]+this.yyleng-u]),this.yyleng=this.yytext.length,this},"unput"),more:a(function(){return this._more=!0,this},"more"),reject:a(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return this.parseError("Lexical error on line "+(this.yylineno+1)+`. You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).
|
|
4
4
|
`+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:a(function(h){this.unput(this.match.slice(h))},"less"),pastInput:a(function(){var h=this.matched.substr(0,this.matched.length-this.match.length);return(h.length>20?"...":"")+h.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:a(function(){var h=this.match;return h.length<20&&(h+=this._input.substr(0,20-h.length)),(h.substr(0,20)+(h.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:a(function(){var h=this.pastInput(),u=new Array(h.length+1).join("-");return h+this.upcomingInput()+`
|
package/dist/index.html
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<!-- iOS Safari PWA Meta Tags -->
|
|
13
13
|
<meta name="mobile-web-app-capable" content="yes" />
|
|
14
14
|
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
15
|
-
<meta name="apple-mobile-web-app-title" content="
|
|
15
|
+
<meta name="apple-mobile-web-app-title" content="Axhub Genie" />
|
|
16
16
|
|
|
17
17
|
<!-- iOS Safari Icons -->
|
|
18
18
|
<link rel="apple-touch-icon" sizes="152x152" href="/icons/icon-152x152.png" />
|
|
@@ -54,10 +54,10 @@
|
|
|
54
54
|
|
|
55
55
|
window.__clearLegacyOfflineState__();
|
|
56
56
|
</script>
|
|
57
|
-
<script type="module" crossorigin src="/assets/index-
|
|
58
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-react-
|
|
59
|
-
<link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-
|
|
60
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
57
|
+
<script type="module" crossorigin src="/assets/index-C514cLyb.js"></script>
|
|
58
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-react-xmA_f8ig.js">
|
|
59
|
+
<link rel="modulepreload" crossorigin href="/assets/vendor-codemirror-CMHSJ_9p.js">
|
|
60
|
+
<link rel="stylesheet" crossorigin href="/assets/index-h1DBl_g3.css">
|
|
61
61
|
</head>
|
|
62
62
|
<body>
|
|
63
63
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@axhub/genie",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.10",
|
|
4
4
|
"description": "A proxy for Claude Code, Codex, Gemini, and OpenCode services",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "server/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"README.md"
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
|
-
"dev": "
|
|
24
|
+
"dev": "node scripts/dev-runner.js",
|
|
25
25
|
"server": "node server/index.js",
|
|
26
26
|
"client": "vite --host",
|
|
27
27
|
"docs:build": "node scripts/generate-api-docs.mjs",
|
|
@@ -42,13 +42,13 @@
|
|
|
42
42
|
"ui",
|
|
43
43
|
"mobile"
|
|
44
44
|
],
|
|
45
|
-
"license": "
|
|
45
|
+
"license": "MIT",
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@agentclientprotocol/sdk": "^0.
|
|
48
|
-
"@anthropic-ai/claude-agent-sdk": "0.
|
|
47
|
+
"@agentclientprotocol/sdk": "^0.18.2",
|
|
48
|
+
"@anthropic-ai/claude-agent-sdk": "^0.2.104",
|
|
49
49
|
"@iarna/toml": "^2.2.5",
|
|
50
50
|
"@larksuiteoapi/node-sdk": "^1.59.0",
|
|
51
|
-
"@openai/codex-sdk": "^0.
|
|
51
|
+
"@openai/codex-sdk": "^0.120.0",
|
|
52
52
|
"bcrypt": "^6.0.0",
|
|
53
53
|
"chokidar": "^4.0.3",
|
|
54
54
|
"cors": "^2.8.5",
|
|
@@ -62,6 +62,7 @@
|
|
|
62
62
|
"multer": "^2.0.1",
|
|
63
63
|
"node-fetch": "^2.7.0",
|
|
64
64
|
"node-pty": "^1.1.0-beta34",
|
|
65
|
+
"qrcode": "^1.5.4",
|
|
65
66
|
"ws": "^8.14.2"
|
|
66
67
|
},
|
|
67
68
|
"devDependencies": {
|
|
@@ -120,4 +121,4 @@
|
|
|
120
121
|
"typescript": "^5.9.3",
|
|
121
122
|
"vite": "^7.0.4"
|
|
122
123
|
}
|
|
123
|
-
}
|
|
124
|
+
}
|
|
@@ -12,7 +12,8 @@ import {
|
|
|
12
12
|
|
|
13
13
|
import {
|
|
14
14
|
CONVERSATION_EVENT_KINDS,
|
|
15
|
-
createConversationEvent
|
|
15
|
+
createConversationEvent,
|
|
16
|
+
stripAssistantProtocolTags
|
|
16
17
|
} from '../../shared/conversationEvents.js';
|
|
17
18
|
import { parseDataUrl } from '../utils/agentImages.js';
|
|
18
19
|
import { spawnCommand } from '../utils/spawnCommand.js';
|
|
@@ -25,6 +26,7 @@ const DEFAULT_TERMINAL_MAX_LIFETIME_MS = parseInt(process.env.ACP_TERMINAL_MAX_L
|
|
|
25
26
|
const FILTERED_CHILD_PROCESS_ENV_KEYS = new Set(['NODE_OPTIONS']);
|
|
26
27
|
|
|
27
28
|
const pendingPermissionRequests = new Map();
|
|
29
|
+
const loggedMalformedUsageUpdates = new Set();
|
|
28
30
|
|
|
29
31
|
function getDisabledClaudeAcpMcpServers() {
|
|
30
32
|
const configured = typeof process.env.CLAUDE_SDK_DISABLED_MCP_SERVERS === 'string'
|
|
@@ -43,6 +45,62 @@ function cloneJsonValue(value) {
|
|
|
43
45
|
return JSON.parse(JSON.stringify(value));
|
|
44
46
|
}
|
|
45
47
|
|
|
48
|
+
function logMalformedUsageUpdate(agentKey, sessionId, used, size) {
|
|
49
|
+
const cacheKey = `${agentKey || 'unknown'}:${sessionId || 'unknown'}:${String(used)}:${String(size)}`;
|
|
50
|
+
if (loggedMalformedUsageUpdates.has(cacheKey)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
loggedMalformedUsageUpdates.add(cacheKey);
|
|
55
|
+
console.warn(
|
|
56
|
+
`[ACP:${agentKey || 'unknown'}] Dropping malformed usage_update notification for session ${sessionId || 'unknown'} (used=${String(used)}, size=${String(size)})`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function sanitizeIncomingAcpMessage(message, agentKey = 'unknown') {
|
|
61
|
+
if (!message || typeof message !== 'object') {
|
|
62
|
+
return message;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const normalizedMethod = String(message.method || '').trim();
|
|
66
|
+
if (normalizedMethod !== 'sessionUpdate' && normalizedMethod !== 'session/update') {
|
|
67
|
+
return message;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const params = message.params;
|
|
71
|
+
const update = params?.update;
|
|
72
|
+
if (!update || typeof update !== 'object' || String(update.sessionUpdate || '').trim() !== 'usage_update') {
|
|
73
|
+
return message;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const used = update.used;
|
|
77
|
+
const size = update.size;
|
|
78
|
+
const hasValidUsed = Number.isInteger(used) && used >= 0;
|
|
79
|
+
const hasValidSize = Number.isInteger(size) && size >= 0;
|
|
80
|
+
|
|
81
|
+
if (hasValidUsed && hasValidSize) {
|
|
82
|
+
return message;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
logMalformedUsageUpdate(agentKey, params?.sessionId, used, size);
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function createSanitizedAcpStream(output, input, agentKey) {
|
|
90
|
+
const baseStream = ndJsonStream(output, input);
|
|
91
|
+
return {
|
|
92
|
+
writable: baseStream.writable,
|
|
93
|
+
readable: baseStream.readable.pipeThrough(new TransformStream({
|
|
94
|
+
transform(message, controller) {
|
|
95
|
+
const sanitized = sanitizeIncomingAcpMessage(message, agentKey);
|
|
96
|
+
if (sanitized) {
|
|
97
|
+
controller.enqueue(sanitized);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}))
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
46
104
|
function filterClaudeMcpServers(config, disabledServers) {
|
|
47
105
|
if (!config || typeof config !== 'object' || Array.isArray(config) || disabledServers.size === 0) {
|
|
48
106
|
return { changed: false, config };
|
|
@@ -925,6 +983,7 @@ export class AcpClient {
|
|
|
925
983
|
this.writer.send({
|
|
926
984
|
provider: this.agentKey,
|
|
927
985
|
sessionId: this.sessionId,
|
|
986
|
+
projectPath: this.projectPath,
|
|
928
987
|
runtime: 'acp',
|
|
929
988
|
timestamp: nowIso(),
|
|
930
989
|
...payload
|
|
@@ -994,19 +1053,31 @@ export class AcpClient {
|
|
|
994
1053
|
);
|
|
995
1054
|
}
|
|
996
1055
|
|
|
997
|
-
reportPromptFailure(error
|
|
1056
|
+
reportPromptFailure(error) {
|
|
998
1057
|
if (this.hasReportedPromptFatalError) {
|
|
999
1058
|
return;
|
|
1000
1059
|
}
|
|
1001
1060
|
|
|
1002
1061
|
this.hasReportedPromptFatalError = true;
|
|
1062
|
+
const errorMessage = error?.message || 'Agent prompt failed.';
|
|
1003
1063
|
|
|
1004
1064
|
const failedAt = nowIso();
|
|
1005
1065
|
this.flushOpenTextStreams(failedAt);
|
|
1066
|
+
this.emitConversationEvent(
|
|
1067
|
+
CONVERSATION_EVENT_KINDS.ERROR,
|
|
1068
|
+
{
|
|
1069
|
+
message: errorMessage
|
|
1070
|
+
},
|
|
1071
|
+
{
|
|
1072
|
+
timestamp: failedAt,
|
|
1073
|
+
sourceType: 'acp-prompt-error'
|
|
1074
|
+
}
|
|
1075
|
+
);
|
|
1006
1076
|
this.emitConversationEvent(
|
|
1007
1077
|
CONVERSATION_EVENT_KINDS.SESSION_STATE_CHANGED,
|
|
1008
1078
|
{
|
|
1009
|
-
state: 'errored'
|
|
1079
|
+
state: 'errored',
|
|
1080
|
+
message: errorMessage
|
|
1010
1081
|
},
|
|
1011
1082
|
{
|
|
1012
1083
|
timestamp: failedAt,
|
|
@@ -1017,13 +1088,6 @@ export class AcpClient {
|
|
|
1017
1088
|
type: 'session-status',
|
|
1018
1089
|
isProcessing: false
|
|
1019
1090
|
});
|
|
1020
|
-
|
|
1021
|
-
if (emitRawError) {
|
|
1022
|
-
this.emitPayload({
|
|
1023
|
-
type: 'error',
|
|
1024
|
-
error: error?.message || 'Agent prompt failed.'
|
|
1025
|
-
});
|
|
1026
|
-
}
|
|
1027
1091
|
}
|
|
1028
1092
|
|
|
1029
1093
|
handleAgentDiagnostic(text) {
|
|
@@ -1051,9 +1115,7 @@ export class AcpClient {
|
|
|
1051
1115
|
|
|
1052
1116
|
if (pendingDiagnostic) {
|
|
1053
1117
|
pendingDiagnostic.handled = true;
|
|
1054
|
-
this.reportPromptFailure(fatalError
|
|
1055
|
-
emitRawError: true
|
|
1056
|
-
});
|
|
1118
|
+
this.reportPromptFailure(fatalError);
|
|
1057
1119
|
pendingDiagnostic.reject(fatalError);
|
|
1058
1120
|
}
|
|
1059
1121
|
|
|
@@ -1248,6 +1310,11 @@ export class AcpClient {
|
|
|
1248
1310
|
|
|
1249
1311
|
if (update.sessionUpdate === 'agent_message_chunk') {
|
|
1250
1312
|
if (update.content?.type === 'text' && typeof update.content.text === 'string') {
|
|
1313
|
+
const cleanText = stripAssistantProtocolTags(update.content.text);
|
|
1314
|
+
if (!cleanText) {
|
|
1315
|
+
return;
|
|
1316
|
+
}
|
|
1317
|
+
|
|
1251
1318
|
const messageId = this.streamState.assistantMessageId
|
|
1252
1319
|
|| this.createAssistantMessageId('assistant_text');
|
|
1253
1320
|
|
|
@@ -1268,7 +1335,7 @@ export class AcpClient {
|
|
|
1268
1335
|
CONVERSATION_EVENT_KINDS.ASSISTANT_TEXT_DELTA,
|
|
1269
1336
|
{
|
|
1270
1337
|
messageId,
|
|
1271
|
-
text:
|
|
1338
|
+
text: cleanText
|
|
1272
1339
|
},
|
|
1273
1340
|
{
|
|
1274
1341
|
timestamp,
|
|
@@ -1379,6 +1446,51 @@ export class AcpClient {
|
|
|
1379
1446
|
return;
|
|
1380
1447
|
}
|
|
1381
1448
|
|
|
1449
|
+
if (update.sessionUpdate === 'config_option_update') {
|
|
1450
|
+
this.emitConversationEvent(
|
|
1451
|
+
CONVERSATION_EVENT_KINDS.CONFIG_OPTION_UPDATE,
|
|
1452
|
+
{
|
|
1453
|
+
configOptions: cloneJsonValue(update.configOptions || [])
|
|
1454
|
+
},
|
|
1455
|
+
{
|
|
1456
|
+
timestamp,
|
|
1457
|
+
sourceType: 'acp-config-option-update'
|
|
1458
|
+
}
|
|
1459
|
+
);
|
|
1460
|
+
return;
|
|
1461
|
+
}
|
|
1462
|
+
|
|
1463
|
+
if (update.sessionUpdate === 'session_info_update') {
|
|
1464
|
+
this.emitConversationEvent(
|
|
1465
|
+
CONVERSATION_EVENT_KINDS.SESSION_INFO_UPDATE,
|
|
1466
|
+
{
|
|
1467
|
+
...(Object.prototype.hasOwnProperty.call(update, 'title') ? { title: update.title ?? null } : {}),
|
|
1468
|
+
...(Object.prototype.hasOwnProperty.call(update, 'updatedAt') ? { updatedAt: update.updatedAt ?? null } : {})
|
|
1469
|
+
},
|
|
1470
|
+
{
|
|
1471
|
+
timestamp,
|
|
1472
|
+
sourceType: 'acp-session-info-update'
|
|
1473
|
+
}
|
|
1474
|
+
);
|
|
1475
|
+
return;
|
|
1476
|
+
}
|
|
1477
|
+
|
|
1478
|
+
if (update.sessionUpdate === 'usage_update') {
|
|
1479
|
+
this.emitConversationEvent(
|
|
1480
|
+
CONVERSATION_EVENT_KINDS.USAGE_UPDATE,
|
|
1481
|
+
{
|
|
1482
|
+
used: update.used,
|
|
1483
|
+
size: update.size,
|
|
1484
|
+
...(update.cost !== undefined ? { cost: cloneJsonValue(update.cost) } : {})
|
|
1485
|
+
},
|
|
1486
|
+
{
|
|
1487
|
+
timestamp,
|
|
1488
|
+
sourceType: 'acp-usage-update'
|
|
1489
|
+
}
|
|
1490
|
+
);
|
|
1491
|
+
return;
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1382
1494
|
if (update.sessionUpdate === 'tool_call' || update.sessionUpdate === 'tool_call_update') {
|
|
1383
1495
|
const existing = this.streamState.toolCalls.get(update.toolCallId) || {
|
|
1384
1496
|
snapshotSignature: null,
|
|
@@ -1495,9 +1607,10 @@ export class AcpClient {
|
|
|
1495
1607
|
}
|
|
1496
1608
|
});
|
|
1497
1609
|
|
|
1498
|
-
const stream =
|
|
1610
|
+
const stream = createSanitizedAcpStream(
|
|
1499
1611
|
Writable.toWeb(this.childProcess.stdin),
|
|
1500
|
-
Readable.toWeb(this.childProcess.stdout)
|
|
1612
|
+
Readable.toWeb(this.childProcess.stdout),
|
|
1613
|
+
this.agentKey
|
|
1501
1614
|
);
|
|
1502
1615
|
|
|
1503
1616
|
this.connection = new ClientSideConnection(() => ({
|
|
@@ -55,6 +55,55 @@ export function resolveDefaultModel(agentKey, requestedModel) {
|
|
|
55
55
|
return normalizedRequestedModel || null;
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
+
function truncateSessionSummary(text, maxLength = 50) {
|
|
59
|
+
const normalizedText = typeof text === 'string' ? text.trim() : '';
|
|
60
|
+
if (!normalizedText) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return normalizedText.length > maxLength
|
|
65
|
+
? `${normalizedText.slice(0, maxLength)}...`
|
|
66
|
+
: normalizedText;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function extractVisibleUserPrompt(value) {
|
|
70
|
+
const text = String(value || '').trim();
|
|
71
|
+
if (!text) {
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (
|
|
76
|
+
text.startsWith('# AGENTS.md instructions for ') ||
|
|
77
|
+
text.includes('<environment_context>') ||
|
|
78
|
+
text.startsWith('<subagent_notification>') ||
|
|
79
|
+
text.startsWith('</subagent_notification>')
|
|
80
|
+
) {
|
|
81
|
+
return '';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (text.startsWith('[DYNAMIC CONTEXT V1]')) {
|
|
85
|
+
const marker = '\n\n[USER MESSAGE]\n';
|
|
86
|
+
const markerIndex = text.indexOf(marker);
|
|
87
|
+
if (markerIndex >= 0) {
|
|
88
|
+
return text.slice(markerIndex + marker.length).trim();
|
|
89
|
+
}
|
|
90
|
+
return '';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const dynamicContextMatch = text.match(
|
|
94
|
+
/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i
|
|
95
|
+
);
|
|
96
|
+
if (dynamicContextMatch) {
|
|
97
|
+
return String(dynamicContextMatch[1] || '').trim();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return text;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function deriveSessionSummaryFromPrompt(command) {
|
|
104
|
+
return truncateSessionSummary(extractVisibleUserPrompt(command));
|
|
105
|
+
}
|
|
106
|
+
|
|
58
107
|
function unregisterActiveClient(provider, sessionId, client = null) {
|
|
59
108
|
const key = createActiveSessionKey(provider, sessionId);
|
|
60
109
|
if (!key) {
|
|
@@ -226,6 +275,7 @@ export async function executeAgentPrompt({ agentKey, command, options = {}, writ
|
|
|
226
275
|
});
|
|
227
276
|
const resolvedModel = resolveDefaultModel(normalizedAgent, options.model);
|
|
228
277
|
const agentCommand = options.agentCommand || null;
|
|
278
|
+
const sessionSummary = deriveSessionSummaryFromPrompt(command);
|
|
229
279
|
let sessionRecord = null;
|
|
230
280
|
let client = null;
|
|
231
281
|
|
|
@@ -253,6 +303,8 @@ export async function executeAgentPrompt({ agentKey, command, options = {}, writ
|
|
|
253
303
|
projectPath: effectiveProjectPath,
|
|
254
304
|
agentCommand,
|
|
255
305
|
model: resolvedModel,
|
|
306
|
+
summary: sessionSummary,
|
|
307
|
+
title: sessionSummary,
|
|
256
308
|
lastActivity: new Date().toISOString(),
|
|
257
309
|
lastPromptAt: new Date().toISOString(),
|
|
258
310
|
isClosed: false
|
|
@@ -271,6 +323,8 @@ export async function executeAgentPrompt({ agentKey, command, options = {}, writ
|
|
|
271
323
|
projectPath: effectiveProjectPath,
|
|
272
324
|
agentCommand,
|
|
273
325
|
model: resolvedModel,
|
|
326
|
+
summary: sessionSummary,
|
|
327
|
+
title: sessionSummary,
|
|
274
328
|
lastActivity: new Date().toISOString(),
|
|
275
329
|
lastPromptAt: new Date().toISOString(),
|
|
276
330
|
isClosed: false
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
import fs from 'fs/promises';
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { readMirroredConversationEvents } from '../session-core/eventStore.js';
|
|
4
5
|
|
|
5
6
|
function parsePositiveInteger(value, fallback) {
|
|
6
7
|
const parsed = parseInt(value, 10);
|
|
7
8
|
return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
|
|
8
9
|
}
|
|
9
10
|
|
|
10
|
-
const ACP_SESSION_ROOT = process.env.AXHUB_GENIE_ACP_SESSION_ROOT
|
|
11
|
-
? path.resolve(process.env.AXHUB_GENIE_ACP_SESSION_ROOT)
|
|
12
|
-
: path.join(os.homedir(), '.axhub-genie', 'acp-sessions');
|
|
13
11
|
const DEFAULT_SESSION_GC_MAX_AGE_DAYS = parsePositiveInteger(process.env.ACP_SESSION_GC_MAX_AGE_DAYS, 30);
|
|
14
12
|
|
|
15
13
|
function normalizeProvider(value) {
|
|
@@ -22,7 +20,10 @@ function normalizeSessionId(value) {
|
|
|
22
20
|
}
|
|
23
21
|
|
|
24
22
|
function getProviderDir(provider) {
|
|
25
|
-
|
|
23
|
+
const sessionRoot = process.env.AXHUB_GENIE_ACP_SESSION_ROOT
|
|
24
|
+
? path.resolve(process.env.AXHUB_GENIE_ACP_SESSION_ROOT)
|
|
25
|
+
: path.join(os.homedir(), '.axhub-genie', 'acp-sessions');
|
|
26
|
+
return path.join(sessionRoot, normalizeProvider(provider));
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
function getSessionFilePath(provider, sessionId) {
|
|
@@ -92,6 +93,73 @@ function createSessionSummary(record) {
|
|
|
92
93
|
};
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
function extractVisibleUserPrompt(value) {
|
|
97
|
+
const text = String(value || '').trim();
|
|
98
|
+
if (!text) {
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (
|
|
103
|
+
text.startsWith('# AGENTS.md instructions for ') ||
|
|
104
|
+
text.includes('<environment_context>') ||
|
|
105
|
+
text.startsWith('<subagent_notification>') ||
|
|
106
|
+
text.startsWith('</subagent_notification>')
|
|
107
|
+
) {
|
|
108
|
+
return '';
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
if (text.startsWith('[DYNAMIC CONTEXT V1]')) {
|
|
112
|
+
const marker = '\n\n[USER MESSAGE]\n';
|
|
113
|
+
const markerIndex = text.indexOf(marker);
|
|
114
|
+
if (markerIndex >= 0) {
|
|
115
|
+
return text.slice(markerIndex + marker.length).trim();
|
|
116
|
+
}
|
|
117
|
+
return '';
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
const dynamicContextMatch = text.match(
|
|
121
|
+
/^<dynamic_context(?:\s[^>]*)?>[\s\S]*?<\/dynamic_context>\s*<user_message>\s*([\s\S]*?)\s*<\/user_message>$/i
|
|
122
|
+
);
|
|
123
|
+
if (dynamicContextMatch) {
|
|
124
|
+
return String(dynamicContextMatch[1] || '').trim();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return text;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function truncateSessionSummary(text, maxLength = 50) {
|
|
131
|
+
const normalizedText = typeof text === 'string' ? text.trim() : '';
|
|
132
|
+
if (!normalizedText) {
|
|
133
|
+
return null;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return normalizedText.length > maxLength
|
|
137
|
+
? `${normalizedText.slice(0, maxLength)}...`
|
|
138
|
+
: normalizedText;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
async function deriveSummaryFromMirroredEvents(record) {
|
|
142
|
+
if (!record?.provider || !record?.sessionId) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const events = await readMirroredConversationEvents(record.provider, record.sessionId);
|
|
147
|
+
for (const event of events) {
|
|
148
|
+
if (event?.kind !== 'user_message') {
|
|
149
|
+
continue;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const rawText = event?.payload?.text || event?.payload?.message || '';
|
|
153
|
+
const visiblePrompt = extractVisibleUserPrompt(rawText);
|
|
154
|
+
const summary = truncateSessionSummary(visiblePrompt);
|
|
155
|
+
if (summary) {
|
|
156
|
+
return summary;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
95
163
|
function getSessionActivityTime(record) {
|
|
96
164
|
return new Date(
|
|
97
165
|
record?.closedAt
|
|
@@ -216,7 +284,13 @@ export async function listAcpSessions({ provider = null, projectPath = null } =
|
|
|
216
284
|
const filePaths = await listProviderSessionFiles(currentProvider);
|
|
217
285
|
for (const filePath of filePaths) {
|
|
218
286
|
const record = await readJsonFile(filePath);
|
|
219
|
-
const
|
|
287
|
+
const hydratedRecord = record && !record.summary
|
|
288
|
+
? {
|
|
289
|
+
...record,
|
|
290
|
+
summary: await deriveSummaryFromMirroredEvents(record)
|
|
291
|
+
}
|
|
292
|
+
: record;
|
|
293
|
+
const summary = createSessionSummary(hydratedRecord);
|
|
220
294
|
if (!summary) {
|
|
221
295
|
continue;
|
|
222
296
|
}
|