@bkm016/basalt 0.1.12 → 0.1.14
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/README.md +3 -2
- package/chunk-03wzwnn6.js +2 -0
- package/{chunk-7jezts2n.js → chunk-06s9pr82.js} +2 -2
- package/{chunk-eyrtbbdd.js → chunk-0crbhhna.js} +1 -1
- package/{chunk-kpe7pnhy.js → chunk-0rasqm8y.js} +4 -4
- package/chunk-1w4nh5t6.js +5 -0
- package/{chunk-02d3x4mj.js → chunk-2eaehpp6.js} +3 -3
- package/{chunk-jj4hqbrx.js → chunk-30dxcr91.js} +3 -3
- package/{chunk-nw1xpt3s.js → chunk-343jsm46.js} +2 -2
- package/{chunk-bk4rpnm8.js → chunk-37ndxehw.js} +2 -2
- package/chunk-38g4jd6v.js +5 -0
- package/{chunk-0fc9apfn.js → chunk-39mh7h58.js} +23 -23
- package/{chunk-6mges89p.js → chunk-44a7f5ta.js} +5 -5
- package/chunk-44b9yx79.js +2 -0
- package/{chunk-jn5pqy5v.js → chunk-46vy2m29.js} +1 -1
- package/{chunk-2kxnw7vs.js → chunk-4f6p4n7k.js} +2 -2
- package/chunk-4w8j6n7z.js +2 -0
- package/{chunk-qs8zzg50.js → chunk-4yxd2kg1.js} +2 -2
- package/{chunk-ksk49hv0.js → chunk-59hg9a84.js} +1 -1
- package/chunk-62ebm0bn.js +2 -0
- package/chunk-6ef085c1.js +20 -0
- package/chunk-6hx9y86d.js +3 -0
- package/chunk-73t051r6.js +2 -0
- package/{chunk-1h34mzh7.js → chunk-7mgkpn94.js} +7 -7
- package/{chunk-w0rr66z7.js → chunk-81x8r8w4.js} +1 -1
- package/chunk-86yr2c0r.js +3 -0
- package/{chunk-ypqjfv3a.js → chunk-8np9b2y8.js} +2 -2
- package/{chunk-hbnmymaq.js → chunk-9ew8cap5.js} +2 -2
- package/chunk-9v3b7jjv.js +2 -0
- package/{chunk-01nve4qy.js → chunk-9vam83py.js} +1 -1
- package/chunk-9xjecw6c.js +2 -0
- package/{chunk-6sz5q3df.js → chunk-b2wpj81x.js} +2 -2
- package/chunk-b516bp7n.js +3 -0
- package/chunk-bjvv3403.js +2 -0
- package/{chunk-hc300148.js → chunk-c8g9jjqs.js} +2 -2
- package/chunk-cs91rmbf.js +18 -0
- package/chunk-drett6hb.js +2 -0
- package/{chunk-fy82qxa1.js → chunk-edcf97ka.js} +1 -1
- package/chunk-en7z6ne5.js +3 -0
- package/{chunk-p2pmdbt2.js → chunk-evnqkyt7.js} +12 -12
- package/{chunk-8mezk0cb.js → chunk-g2etemv5.js} +2 -2
- package/{chunk-n0ybj4h9.js → chunk-g5p9mj1r.js} +2 -2
- package/{chunk-eq4wqxzt.js → chunk-ge38dhv9.js} +2 -2
- package/chunk-hggam3je.js +2 -0
- package/chunk-k38jaz6c.js +7 -0
- package/{chunk-qfcr5g35.js → chunk-kcn05erf.js} +3 -3
- package/{chunk-rwks9zaw.js → chunk-m5km74eq.js} +2 -2
- package/{chunk-jpnf71q7.js → chunk-mfb3dgs8.js} +2 -2
- package/{chunk-vjne04dp.js → chunk-mh4bjtfs.js} +4 -4
- package/chunk-nysatg77.js +4161 -0
- package/chunk-p886jr17.js +25 -0
- package/{chunk-82v8jh1h.js → chunk-pdt65s31.js} +2 -2
- package/chunk-pjgt1bdx.js +3 -0
- package/{chunk-tvm4zmgj.js → chunk-pyj6avd5.js} +2 -2
- package/chunk-qd2enpr2.js +3 -0
- package/{chunk-cbgpymt4.js → chunk-qe76naq9.js} +1 -1
- package/{chunk-ntks40jd.js → chunk-qjnx4fsn.js} +5 -5
- package/{chunk-fhxy6y34.js → chunk-qs161f2q.js} +2 -2
- package/{chunk-v7wcchy2.js → chunk-rghqprav.js} +1 -1
- package/chunk-t33bm5aa.js +2 -0
- package/{chunk-nrsd810j.js → chunk-tfhp09nj.js} +2 -2
- package/chunk-vd5332ps.js +2 -0
- package/{chunk-3pf1d62g.js → chunk-vqm94hz2.js} +2 -2
- package/{chunk-85v69h91.js → chunk-w55cnj0f.js} +2 -2
- package/{chunk-1zj3zvw5.js → chunk-wnd3y4c0.js} +4 -4
- package/{chunk-stj493dn.js → chunk-xafx1p7z.js} +2 -2
- package/{chunk-9as0p561.js → chunk-xf7zw32f.js} +14 -14
- package/chunk-xk3t5ves.js +482 -0
- package/{chunk-5wnmbc1b.js → chunk-xq74x4gc.js} +2 -2
- package/chunk-y0274xr2.js +7 -0
- package/{chunk-ejjem0tc.js → chunk-z9p6s986.js} +6 -6
- package/chunk-zcwz44db.js +2 -0
- package/{chunk-w6f2r052.js → chunk-zhyzhekt.js} +1 -1
- package/compiled.js +85 -12
- package/package.json +1 -1
- package/ui-test-worker.js +65 -65
- package/web/chunk-15g9pnzy.js +1 -0
- package/web/{chunk-4f6a8dsk.js → chunk-17wwzrp4.js} +1 -1
- package/web/chunk-19tkjg9w.js +1 -0
- package/web/chunk-1y387f45.js +1 -0
- package/web/{chunk-30aeb767.js → chunk-25sn840r.js} +2 -2
- package/web/chunk-26sp6jre.js +1 -0
- package/web/{chunk-81s15c2e.js → chunk-2c7kxr4v.js} +2 -2
- package/web/{chunk-wvrs986a.js → chunk-2gsf89vs.js} +3 -3
- package/web/{chunk-3qxxrwsp.js → chunk-2gvz70wr.js} +10 -10
- package/web/chunk-2s3my1jn.js +1 -0
- package/web/{chunk-ar6jnhm5.js → chunk-32dh0hft.js} +1 -1
- package/web/{chunk-3rkkp6ed.js → chunk-3haw3wcw.js} +5 -5
- package/web/{chunk-hn8m1vsg.js → chunk-3rxhs9qm.js} +7 -7
- package/web/chunk-410qdvmv.js +1 -0
- package/web/chunk-4qehf2xx.js +2 -0
- package/web/{chunk-qdd3bx8q.js → chunk-51b8n5e1.js} +1 -1
- package/web/chunk-54mgncq3.js +1 -0
- package/web/{chunk-r6kk4vp1.js → chunk-59g6rrew.js} +4 -4
- package/web/{chunk-7tkgbbf9.js → chunk-5d9veaef.js} +2 -2
- package/web/chunk-6481wt3t.js +1 -0
- package/web/chunk-6ehecat3.js +1 -0
- package/web/chunk-6m8hq6ph.js +1 -0
- package/web/chunk-73941p08.js +1 -0
- package/web/{chunk-aeymdtm1.js → chunk-783s8jds.js} +3 -3
- package/web/{chunk-g4zm0crw.js → chunk-78m018ya.js} +1 -1
- package/web/chunk-797bh7z6.js +39 -0
- package/web/{chunk-hva7xyne.js → chunk-7hpqrfgg.js} +2 -2
- package/web/{chunk-enwfd8d5.js → chunk-7kywe73f.js} +2 -2
- package/web/chunk-7qq1ypvj.js +1 -0
- package/web/{chunk-xbyrgyy0.js → chunk-7wzszsf5.js} +2 -2
- package/web/{chunk-aa46mrgh.js → chunk-7zfqppsx.js} +2 -2
- package/web/{chunk-d73zkc4q.js → chunk-8sr9w61v.js} +3 -3
- package/web/{chunk-v34mr9ky.js → chunk-8ttp8fh3.js} +6 -6
- package/web/chunk-8zg89764.js +1 -0
- package/web/{chunk-2cyzaqjy.js → chunk-988e9wx6.js} +3 -3
- package/web/{chunk-k4dnjf8n.js → chunk-9h0f3gar.js} +3 -3
- package/web/chunk-9vr6hpmk.js +34 -0
- package/web/chunk-9vrp249f.js +2 -0
- package/web/{chunk-td83xf12.js → chunk-a205cj09.js} +2 -2
- package/web/{chunk-gkmaryr4.js → chunk-ahn2frbt.js} +1 -1
- package/web/{chunk-5g8md2wg.js → chunk-aknsydan.js} +5 -5
- package/web/chunk-at0xtfhy.js +1 -0
- package/web/chunk-bahccwb9.js +1 -0
- package/web/{chunk-rdr6wt22.js → chunk-c7fqrs8j.js} +4 -4
- package/web/chunk-d3hyf9yd.js +1 -0
- package/web/chunk-dcegr80c.js +1 -0
- package/web/{chunk-act3rr85.js → chunk-dwtatme7.js} +1 -1
- package/web/{chunk-5np514v5.js → chunk-ex8rmqn1.js} +12 -12
- package/web/{chunk-g488hxx0.js → chunk-faskbfjf.js} +3 -3
- package/web/chunk-feanedhx.js +1 -0
- package/web/{chunk-e94pd9rr.js → chunk-ffywf5w5.js} +10 -10
- package/web/chunk-fx3d48e6.js +1 -0
- package/web/{chunk-ncfzmf2g.js → chunk-g3szt4c4.js} +1 -1
- package/web/chunk-g7bcntpm.js +1 -0
- package/web/chunk-gr1tjqbd.js +1 -0
- package/web/{chunk-bygwbpvq.js → chunk-hbwxtbq3.js} +2 -2
- package/web/{chunk-gten0rpx.js → chunk-hdtvrh0f.js} +2 -2
- package/web/chunk-j031r08w.js +1 -0
- package/web/{chunk-d57fm7k0.js → chunk-j6wcszxq.js} +2 -2
- package/web/{chunk-885kpj14.js → chunk-jdx7qp2w.js} +2 -2
- package/web/chunk-jge7nn3s.js +1 -0
- package/web/chunk-jy8zat04.js +1 -0
- package/web/{chunk-7vgh17es.js → chunk-jzge034r.js} +1 -1
- package/web/{chunk-fj753yzt.js → chunk-k4qrqmdk.js} +2 -2
- package/web/chunk-k8s7kye3.js +1 -0
- package/web/{chunk-2jfesv7m.js → chunk-k9fyqrhp.js} +2 -2
- package/web/chunk-k9zn1n6d.js +1 -0
- package/web/chunk-kg3tksv7.js +1 -0
- package/web/chunk-kk5rw81s.js +2 -0
- package/web/{chunk-xpecre7w.js → chunk-kpmd893m.js} +4 -4
- package/web/chunk-md9j949p.js +1 -0
- package/web/{chunk-jeafmjsm.js → chunk-mn2wv9ye.js} +6 -6
- package/web/{chunk-dndd757x.js → chunk-mv7jgmnb.js} +3 -3
- package/web/{chunk-c3fty2c2.js → chunk-mvm68qtt.js} +7 -7
- package/web/chunk-nbcpbqq4.js +1 -0
- package/web/{chunk-b99k8q22.js → chunk-nfpff7yf.js} +8 -8
- package/web/chunk-nk7jkpam.js +1 -0
- package/web/chunk-nmvt1rn3.js +1 -0
- package/web/chunk-npw1s1h2.js +1 -0
- package/web/chunk-npyrdsf8.css +1 -0
- package/web/chunk-nzzxv84v.js +8 -0
- package/web/{chunk-n9v14vyd.js → chunk-p4pqtybm.js} +22 -22
- package/web/{chunk-jyf7a7yp.js → chunk-p79c7aak.js} +1 -1
- package/web/{chunk-6jb2zyp6.js → chunk-pafw34vg.js} +2 -2
- package/web/{chunk-y2rzeb4v.js → chunk-pf65cank.js} +2 -2
- package/web/{chunk-d1btrqmw.js → chunk-ppa21760.js} +1 -1
- package/web/{chunk-60mym60n.js → chunk-ptpkv0te.js} +1 -1
- package/web/{chunk-yjs6jmdb.js → chunk-qcdej581.js} +3 -3
- package/web/{chunk-q1zxvjhs.js → chunk-qftcdcps.js} +2 -2
- package/web/{chunk-4wwd3pfz.js → chunk-qv1w36ja.js} +2 -2
- package/web/chunk-r8p741qj.js +2 -0
- package/web/chunk-rcexbkjj.js +1 -0
- package/web/{chunk-kerfb21g.js → chunk-rjakb64x.js} +1 -1
- package/web/{chunk-k0cg4n2k.js → chunk-s0xy00v5.js} +2 -2
- package/web/{chunk-ym7kv2hs.js → chunk-s2ps0ct5.js} +1 -1
- package/web/{chunk-h24ybwp6.js → chunk-s45g7fp6.js} +1 -1
- package/web/{chunk-pjpre6de.js → chunk-s70aj1v5.js} +6 -6
- package/web/chunk-say8bvkc.js +1 -0
- package/web/{chunk-qh62nkem.js → chunk-sd3cdqcm.js} +2 -2
- package/web/{chunk-6f2sz84q.js → chunk-sgkevxdf.js} +2 -2
- package/web/chunk-sjffrcq9.js +1 -0
- package/web/{chunk-19zd0tye.js → chunk-snaepr87.js} +8 -8
- package/web/{chunk-3n9ypydh.js → chunk-tdzh6nsz.js} +2 -2
- package/web/{chunk-wqzbxzk3.js → chunk-tjd8qp87.js} +1 -1
- package/web/chunk-tncc9e57.js +1 -0
- package/web/chunk-ty2rmwda.js +1142 -0
- package/web/chunk-v22hp18w.js +1 -0
- package/web/chunk-ve9dz857.js +2 -0
- package/web/{chunk-80z8s8zb.js → chunk-vg346gxc.js} +2 -2
- package/web/{chunk-hqxc9m07.js → chunk-vpegzgzb.js} +10 -10
- package/web/{chunk-pzg25qqe.js → chunk-vvvd3grf.js} +2 -2
- package/web/{chunk-qp3tjhaq.js → chunk-vwv6pqy7.js} +1 -1
- package/web/{chunk-3psgr0q8.js → chunk-vxm7n7w6.js} +20 -20
- package/web/{chunk-h754ntg7.js → chunk-w5q7978e.js} +1 -1
- package/web/{chunk-xvfeq8v2.js → chunk-we4mhfmq.js} +12 -12
- package/web/{chunk-8539865x.js → chunk-wfgrdabk.js} +1 -1
- package/web/{chunk-sdr5wa4z.js → chunk-wkhj4hsw.js} +4 -4
- package/web/{chunk-7ksg3ccg.js → chunk-wspk8qbg.js} +2 -2
- package/web/{chunk-hxbfkdjd.js → chunk-xf1hnpme.js} +1 -1
- package/web/{chunk-v1hfbjz9.js → chunk-xhqvzmfj.js} +5 -5
- package/web/chunk-xq70hgre.js +1 -0
- package/web/chunk-xtss82z2.js +1 -0
- package/web/{chunk-yf8ykk4v.js → chunk-y3tb6410.js} +3 -3
- package/web/{chunk-7v85yvb2.js → chunk-y6mcxfm0.js} +1 -1
- package/web/{chunk-7adsmqv6.js → chunk-ya696bfe.js} +2 -2
- package/web/{chunk-w9gnqkez.js → chunk-ysw5fs45.js} +3 -3
- package/web/chunk-zkq1xknc.js +1 -0
- package/web/chunk-zkv025s5.js +1 -0
- package/web/{chunk-8cnjd0f2.js → chunk-zpzvz973.js} +28 -28
- package/web/{chunk-b5zf1hs3.js → chunk-zsat72qd.js} +120 -120
- package/web/chunk-zx3h7v72.js +1 -0
- package/web/index.html +1 -1
- package/worker.js +1 -1
- package/chunk-1xfv4bd7.js +0 -2
- package/chunk-2fyjph3f.js +0 -2
- package/chunk-37zystxb.js +0 -25
- package/chunk-3k627vf2.js +0 -3
- package/chunk-4gtgqcct.js +0 -5
- package/chunk-7er5pz7s.js +0 -479
- package/chunk-7g5smgjj.js +0 -2
- package/chunk-7m3jagqn.js +0 -2
- package/chunk-9c4gdg1q.js +0 -3
- package/chunk-b2bxqeb4.js +0 -2
- package/chunk-bpw6q7g0.js +0 -3
- package/chunk-bwawt15q.js +0 -3
- package/chunk-cdw03j4t.js +0 -20
- package/chunk-ch1r3ted.js +0 -2
- package/chunk-cmwdjes8.js +0 -18
- package/chunk-db7ws33a.js +0 -7
- package/chunk-e1x629v0.js +0 -5
- package/chunk-j64dc767.js +0 -3
- package/chunk-m4bg1apa.js +0 -7
- package/chunk-nhm9z3d8.js +0 -2
- package/chunk-pnspvnyd.js +0 -2
- package/chunk-qnkrrwmg.js +0 -2
- package/chunk-r4gm8ngh.js +0 -2
- package/chunk-rks90mh1.js +0 -2
- package/chunk-t7te60m7.js +0 -2
- package/chunk-tv52xajf.js +0 -2
- package/chunk-wqqjzsjt.js +0 -3983
- package/chunk-xef4642x.js +0 -3
- package/web/chunk-04drx71p.js +0 -1
- package/web/chunk-0mdf1qja.js +0 -1
- package/web/chunk-0rdgt4jb.css +0 -1
- package/web/chunk-1m0kp0g3.js +0 -8
- package/web/chunk-3j2tcphs.js +0 -1
- package/web/chunk-3k9h7a73.js +0 -1142
- package/web/chunk-3m1bb2fw.js +0 -1
- package/web/chunk-55nvm2mj.js +0 -1
- package/web/chunk-5dkqfnh7.js +0 -2
- package/web/chunk-7ky5nrrr.js +0 -1
- package/web/chunk-8sdjgv3k.js +0 -1
- package/web/chunk-9bxtzwtc.js +0 -1
- package/web/chunk-9jy8nc4r.js +0 -1
- package/web/chunk-aebrw6cv.js +0 -39
- package/web/chunk-bcjgzwef.js +0 -1
- package/web/chunk-bra33pt0.js +0 -2
- package/web/chunk-cxpnj495.js +0 -2
- package/web/chunk-d94t9z70.js +0 -1
- package/web/chunk-de29pe57.js +0 -1
- package/web/chunk-e68jw0bg.js +0 -1
- package/web/chunk-fr4fft89.js +0 -1
- package/web/chunk-gckmcef6.js +0 -1
- package/web/chunk-gnb09wmx.js +0 -1
- package/web/chunk-gx340asc.js +0 -1
- package/web/chunk-hrgqc1vr.js +0 -1
- package/web/chunk-j9c8fa82.js +0 -1
- package/web/chunk-jz5mmp64.js +0 -1
- package/web/chunk-kxeaj44h.js +0 -1
- package/web/chunk-m0136xav.js +0 -1
- package/web/chunk-m1rdyvb5.js +0 -1
- package/web/chunk-m6vyvgm5.js +0 -1
- package/web/chunk-mxkbmgcv.js +0 -2
- package/web/chunk-my0ec787.js +0 -1
- package/web/chunk-mzzaet63.js +0 -1
- package/web/chunk-nkpdd9hw.js +0 -1
- package/web/chunk-ny436sqg.js +0 -1
- package/web/chunk-pbp1p5ex.js +0 -1
- package/web/chunk-ph75hddv.js +0 -1
- package/web/chunk-phdfyqaa.js +0 -1
- package/web/chunk-phxa5krt.js +0 -1
- package/web/chunk-r4zbw4zj.js +0 -2
- package/web/chunk-ry4ycah9.js +0 -1
- package/web/chunk-sqm16fat.js +0 -1
- package/web/chunk-tj1fn8v2.js +0 -1
- package/web/chunk-v0wtk059.js +0 -34
- package/web/chunk-v1qt3gq4.js +0 -1
- package/web/chunk-v854w9yn.js +0 -1
- package/web/chunk-ve56gxq0.js +0 -1
- package/web/chunk-w573ym17.js +0 -1
- package/web/chunk-x0mjydtp.js +0 -1
- package/web/chunk-zhybh04p.js +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
function
|
|
2
|
-
export{
|
|
1
|
+
function zn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e<n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e<f||e===void 0&&f>=f))e=f}return e}function yn(i,d){let e;if(d===void 0){for(let n of i)if(n!=null&&(e>n||e===void 0&&n>=n))e=n}else{let n=-1;for(let f of i)if((f=d(f,++n,i))!=null&&(e>f||e===void 0&&f>=f))e=f}return e}
|
|
2
|
+
export{zn,yn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{h,o,G,i,r,m,e,n,y,an,nr,ze,On,Ie,fn,oe,Q,sa,Ro,la}from"./chunk-ty2rmwda.js";function de(d){let{Button:b,confirm:L,PageLayout:x,Switch:_,cn:F,style:z}=y(),{connection:f,onOpen:O}=d,[D,p]=r([]),[w,H]=r([]),[q,J]=r([]),[I,T]=r(),[B,U]=r([]),[A,V]=r(!0),[k,N]=r(),[C,R]=r(),[W,P]=r(!1),[K,c]=r({}),s=i(0),E=h(async()=>{let t=++s.current;try{let[a,l,u,g]=await Promise.all([f.request("/api/automations"),f.request("/api/projects").catch(()=>[]),f.request("/api/info").catch(()=>{return}),f.request("/api/models").catch(()=>({models:[]}))]),te=[...new Set(a.flatMap((v)=>v.lastSessionID?[v.lastSessionID]:[]))],ne=(await Promise.all(te.map(async(v)=>f.request(`/api/sessions/${encodeURIComponent(v)}`).catch((j)=>{if(j instanceof Error&&"status"in j&&j.status===404)return;throw j})))).filter((v)=>v!==void 0);if(t!==s.current)return;if(p(a.sort((v,j)=>v.created-j.created)),H(l),J(ne),T(u),g?.models)U(g.models.map((v)=>v.id));N(void 0)}catch(a){if(t===s.current)N(a instanceof Error?a.message:"加载失败")}finally{if(t===s.current)V(!1)}},[f]);o(()=>(E(),()=>{s.current++}),[E]);let S=(t)=>{R(t),P(!0)},Y=async(t)=>{c((a)=>({...a,[t.id]:!0}));try{let a=await f.request(`/api/automations/${t.id}/run`,{method:"POST"});O(a.id)}catch(a){N(a instanceof Error?a.message:"运行失败")}finally{c((a)=>({...a,[t.id]:!1}))}},Z=async(t)=>{if(!await L({title:`删除自动化「${t.name}」?`,description:"已经跑出来的会话会保留。",action:"删除",danger:!0}))return;try{await f.request(`/api/automations/${t.id}`,{method:"DELETE"}),p((l)=>l.filter((u)=>u.id!==t.id))}catch(l){N(l instanceof Error?l.message:"删除失败")}},ee=async(t,a)=>{try{let l=await f.request(`/api/automations/${t.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({enabled:a})});p((u)=>u.map((g)=>g.id===t.id?l:g))}catch(l){N(l instanceof Error?l.message:"状态切换失败")}};return n(x,{title:"自动化",description:n(m,{children:["到点自动开一个新会话执行提示词,跑完的结果在会话里查看。",I?.timezone&&n("span",{className:"text-faint",children:["按服务器时区 ",I.timezone,"。"]})]}),actions:n(b,{variant:"primary",onClick:()=>S(null),children:[e(oe,{className:"size-4"}),"新建"]}),children:[k&&e("div",{className:"mb-4 rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:k}),A?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载自动化…"}):D.length===0?n("div",{className:z("surface.emptyDashed","animate-fade"),children:[e("div",{className:"grid size-11 place-items-center rounded-xl bg-raised text-dim",children:e(an,{className:"size-5"})}),n("div",{children:[e("p",{className:"text-[15px] font-medium",children:"还没有自动化"}),e("p",{className:"mt-1 text-sm text-dim",children:"比如「每个工作日 9 点总结昨天的提交」。"})]}),n(b,{size:"sm",onClick:()=>S(null),className:"mt-1",children:[e(oe,{className:"size-3.5"}),"新建自动化"]})]}):e("ul",{className:"flex animate-fade flex-col gap-3",children:D.map((t)=>{let a=t.projectID?w.find((g)=>g.id===t.projectID):void 0,l=t.lastSessionID?q.find((g)=>g.id===t.lastSessionID):void 0,u=Boolean(K[t.id]);return e("li",{children:n("article",{className:z("surface.card","group p-4 transition-[border-color,box-shadow] duration-200 hover:border-line-strong hover:shadow-composer"),children:[n("div",{className:"flex items-start gap-3",children:[n("div",{className:F("min-w-0 flex-1 transition-opacity duration-200",!t.enabled&&"opacity-55"),children:[e("h2",{className:"truncate text-[15px] font-medium",children:t.name}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3.5 gap-y-1 text-[13px] text-dim",children:[n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(an,{}),Ro(t.schedule)]}),n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[a?e(ze,{}):e(On,{}),a?a.name:"聊天"]}),t.enabled&&t.nextRun!==null&&n("span",{className:"flex items-center gap-1.5 [&_svg]:size-3.5 [&_svg]:text-faint",children:[e(nr,{}),"下次 ",la(t.nextRun)]})]})]}),e(_,{checked:t.enabled,label:t.enabled?"停用":"启用",onCheckedChange:(g)=>ee(t,g),className:"mt-0.5"})]}),e("p",{className:F("mt-3 line-clamp-2 text-sm leading-6 whitespace-pre-wrap text-faint transition-opacity duration-200",!t.enabled&&"opacity-55"),children:t.prompt}),n("div",{className:"mt-3 -mb-1 flex items-center gap-1",children:[n(b,{size:"sm",onClick:()=>Y(t),disabled:u,children:[e(fn,{className:"size-3.5"}),u?"正在启动…":"立即运行"]}),n(b,{size:"sm",variant:"ghost",onClick:()=>S(t),children:[e(Ie,{className:"size-3.5"}),"编辑"]}),n(b,{size:"sm",variant:"danger-ghost",onClick:()=>Z(t),children:[e(Q,{className:"size-3.5"}),"删除"]}),e("div",{className:"flex-1"}),t.lastRun!==null&&n("button",{type:"button",disabled:!l,onClick:()=>l&&O(l.id),className:"rounded-md px-1.5 py-1 text-[13px] text-faint transition-colors enabled:hover:bg-raised enabled:hover:text-ink",children:["上次运行 ",la(t.lastRun),l?.archivedAt!=null?" · 已归档":"",!l?" · 会话已删除":""]})]})]})},t.id)})}),C!==void 0&&e(se,{open:W,onOpenChange:P,automation:C??void 0,projects:w,models:B,timezone:I?.timezone,onSaved:(t)=>{p((a)=>{let l=a.findIndex((u)=>u.id===t.id);if(l>=0){let u=[...a];return u[l]=t,u}return[...a,t].sort((u,g)=>u.created-g.created)}),P(!1)},connection:f},C?.id??"new")]})}var M="custom",X="chat";function se(d){let{Button:b,Dialog:L,Field:x,Form:_,FormError:F,Input:z,Select:f,Textarea:O}=y(),D=G(),p=d.automation,[w,H]=r(p?.name??""),[q,J]=r(p?.prompt??""),[I,T]=r(p?.schedule??sa[0]?.cron??"0 9 * * *"),[B,U]=r(()=>!sa.some((c)=>c.cron===I)),[A,V]=r(p?.projectID??X),[k,N]=r(p?.model??""),[C,R]=r(!1),[W,P]=r();async function K(c){c.preventDefault(),R(!0),P(void 0);try{let s=A===X?void 0:A,E={name:w,prompt:q,schedule:I,model:k||void 0},S;if(p)S=await d.connection.request(`/api/automations/${p.id}`,{method:"PATCH",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s??null})});else S=await d.connection.request("/api/automations",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({...E,projectID:s})});d.onSaved(S)}catch(s){P(s instanceof Error?s.message:"保存失败")}finally{R(!1)}}return e(L,{open:d.open,onOpenChange:d.onOpenChange,title:d.automation?"编辑自动化":"新建自动化",size:"lg",footer:n(m,{children:[e("div",{className:"flex-1 max-sm:hidden"}),e(b,{onClick:()=>d.onOpenChange(!1),children:"取消"}),e(b,{type:"submit",form:D,variant:"primary",disabled:C,children:C?"正在保存…":d.automation?"保存":"创建"})]}),children:n(_,{id:D,onSubmit:K,children:[e(x,{label:"名称",children:(c)=>e(z,{id:c,autoFocus:!p,required:!0,value:w,onChange:(s)=>H(s.target.value),placeholder:"例如:每日提交总结"})}),e(x,{label:"提示词",hint:"没人盯着运行,写清楚要做什么、结果怎么汇报。",children:(c)=>e(O,{id:c,required:!0,value:q,onChange:(s)=>J(s.target.value),rows:5,placeholder:"总结昨天到现在的 git 提交,按模块分组,列出需要我关注的改动。"})}),n("div",{className:"grid gap-x-3 gap-y-4 sm:grid-cols-2",children:[e(x,{label:"时间",children:(c)=>e(f,{id:c,value:B?M:I,onValueChange:(s)=>{if(U(s===M),s!==M)T(s)},groups:[{options:sa.map((s)=>({value:s.cron,label:s.label}))},{options:[{value:M,label:"自定义(cron)"}]}]})}),e(x,{label:"在哪里运行",children:(c)=>e(f,{id:c,value:A,onValueChange:V,groups:[{options:[{value:X,label:"聊天",description:"不绑定目录",icon:e(On,{})}]},...d.projects.length?[{label:"项目",options:d.projects.map((s)=>({value:s.id,label:s.name,icon:e(ze,{})}))}]:[]]})})]}),B&&e(x,{label:"cron 表达式",hint:`分 时 日 月 周,例如 30 8 * * 1-5 是工作日 8:30。${d.timezone?`按 ${d.timezone} 时间。`:""}`,children:(c)=>e(z,{id:c,required:!0,value:I,onChange:(s)=>T(s.target.value),spellCheck:!1,className:"font-mono"})}),d.models.length>0&&e(x,{label:"模型",children:(c)=>e(f,{id:c,value:k||"default",onValueChange:(s)=>N(s==="default"?"":s),groups:[{options:[{value:"default",label:"默认模型"},...d.models.map((s)=>({value:s,label:s}))]}]})}),e(F,{children:W})]})})}export{de as AutomationsPage};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{H}from"./chunk-
|
|
1
|
+
import{H}from"./chunk-p79c7aak.js";import{t,a,we,N,x,F,C,S,E,T,A,L,R,V,j}from"./chunk-zsat72qd.js";import{J}from"./chunk-p4pqtybm.js";var ht=t(()=>({domains:new Map,transitions:[]}),"createDefaultData"),ot=ht(),St=t(()=>ot.domains,"getDomains"),Mt=t(()=>ot.transitions,"getTransitions"),zt=t((e)=>{if(!e)return;for(let n of e){let o=n.domain,r=(n.items??[]).map((l)=>({label:l.label}));ot.domains.set(o,{name:o,items:r})}},"setDomains"),Lt=t((e)=>{if(!e)return;ot.transitions=e.filter((n)=>{if(n.from===n.to)return a.warn(`Cynefin: self-loop transition on domain "${n.from}" is not meaningful and will be skipped.`),!1;return!0}).map((n)=>({from:n.from,to:n.to,label:n.label||void 0}))},"setTransitions"),Nt=t(()=>j({...N.cynefin,...x().cynefin}),"getConfig"),Pt=t(()=>{C(),ot=ht()},"clear"),it={getDomains:St,getTransitions:Mt,setDomains:zt,setTransitions:Lt,getConfig:Nt,clear:Pt,setAccTitle:S,getAccTitle:E,setDiagramTitle:L,getDiagramTitle:R,getAccDescription:A,setAccDescription:T},It=t((e)=>{H(e,it),it.setDomains(e.domains),it.setTransitions(e.transitions)},"populate"),Wt={parse:t(async(e)=>{let n=await J("cynefin",e);a.debug(n),It(n)},"parse")};function nt(e){let n=e+1831565813|0;return n=Math.imul(n^n>>>15,n|1),n^=n+Math.imul(n^n>>>7,n|61),((n^n>>>14)>>>0)/4294967296}t(nt,"seededRandom");function xt(e){let n=0;for(let o=0;o<e.length;o++){let r=e.charCodeAt(o);n=(n<<5)-n+r,n|=0}return n}t(xt,"hashString");function $t(e,n){if(typeof e==="number"&&Number.isFinite(e)&&e!==0)return e;return xt(n)}t($t,"resolveSeed");function bt(e,n,o,r){let l=e/2,p=r??e*0.015,at=7,Q=n/7,f=[];for(let i=0;i<=7;i++){let y=nt(o+i*17)*p*2-p;f.push({x:l+y,y:i*Q})}let M=`M${f[0].x},${f[0].y}`;for(let i=0;i<f.length-1;i++){let y=f[i],c=f[i+1],m=(y.y+c.y)/2,D=i%2===0?1:-1,h=p*1.5*D*nt(o+i*31+7),Z=y.x+h,K=m,tt=c.x-h;M+=` C${Z},${K} ${tt},${m} ${c.x},${c.y}`}return M}t(bt,"generateFoldPath");function wt(e,n,o,r){let l=n/2,p=r??n*0.015,at=7,Q=e/7,f=[];for(let i=0;i<=7;i++){let y=nt(o+i*23)*p*2-p;f.push({x:i*Q,y:l+y})}let M=`M${f[0].x},${f[0].y}`;for(let i=0;i<f.length-1;i++){let y=f[i],c=f[i+1],m=(y.x+c.x)/2,D=i%2===0?1:-1,h=p*1.5*D*nt(o+i*37+11),Z=m,K=y.y+h,tt=m,Y=c.y-h;M+=` C${Z},${K} ${tt},${Y} ${c.x},${c.y}`}return M}t(wt,"generateHorizontalBoundary");function Ct(e,n){let o=e/2,r=n*0.5,l=n,p=e*0.03;return[`M${o},${r}`,`C${o+p},${r+(l-r)*0.2}`,`${o-p*1.5},${r+(l-r)*0.55}`,`${o+p*0.5},${r+(l-r)*0.75}`,`C${o-p},${r+(l-r)*0.85}`,`${o+p*0.3},${r+(l-r)*0.95}`,`${o},${l}`].join(" ")}t(Ct,"generateCliffPath");function vt(e,n,o,r){return[`M${e-o},${n}`,`A${o},${r} 0 1,1 ${e+o},${n}`,`A${o},${r} 0 1,1 ${e-o},${n}`,"Z"].join(" ")}t(vt,"generateConfusionPath");var gt={complex:{model:"Probe → Sense → Respond",practice:"Emergent Practices"},complicated:{model:"Sense → Analyse → Respond",practice:"Good Practices"},clear:{model:"Sense → Categorise → Respond",practice:"Best Practices"},chaotic:{model:"Act → Sense → Respond",practice:"Novel Practices"},confusion:{model:"",practice:"Disorder"}},Rt=t((e,n)=>{let o=e/2,r=n/2;return{complex:{cx:o/2,cy:r/2,x:0,y:0,w:o,h:r},complicated:{cx:o+o/2,cy:r/2,x:o,y:0,w:o,h:r},chaotic:{cx:o/2,cy:r+r/2,x:0,y:r,w:o,h:r},clear:{cx:o+o/2,cy:r+r/2,x:o,y:r,w:o,h:r},confusion:{cx:o,cy:r,x:o*0.7,y:r*0.7,w:o*0.6,h:r*0.6}}},"getDomainLayouts"),Ft=t(()=>{let e=we(),n=x();return j(e,n.themeVariables).cynefin},"getCynefinDomainColors"),lt=3,Vt=t((e,n,o,r)=>{let l=r.db,p=l.getDomains(),at=l.getTransitions(),Q=l.getDiagramTitle(),f=l.getAccTitle(),M=l.getAccDescription(),i=l.getConfig(),y=Ft();a.debug("Rendering Cynefin diagram");let{width:c,height:m,padding:D,showDomainDescriptions:h,boundaryAmplitude:Z}=i,K=c+D*2,tt=m+D*2,Y={complex:y.complexBg,complicated:y.complicatedBg,clear:y.clearBg,chaotic:y.chaoticBg,confusion:y.confusionBg},z=V(n);if(F(z,tt,K,i.useMaxWidth??!0),z.attr("viewBox",`0 0 ${K} ${tt}`),f)z.append("title").text(f);if(M)z.append("desc").text(M);let P=z.append("g").attr("transform",`translate(${D}, ${D})`),et=Rt(c,m),dt=$t(i.seed,n),Dt=P.append("g").attr("class","cynefin-backgrounds"),st=["complex","complicated","chaotic","clear"];for(let d of st){let s=et[d];Dt.append("rect").attr("class","cynefinDomain").attr("x",s.x).attr("y",s.y).attr("width",s.w).attr("height",s.h).attr("fill",Y[d]).attr("fill-opacity",0.4).attr("stroke","none")}let ct=P.append("g").attr("class","cynefin-boundaries");ct.append("path").attr("class","cynefinBoundary").attr("d",bt(c,m,dt,Z)).attr("fill","none"),ct.append("path").attr("class","cynefinBoundary").attr("d",wt(c,m,dt+100,Z)).attr("fill","none"),ct.append("path").attr("class","cynefinCliff").attr("d",Ct(c,m)).attr("fill","none");let kt=c*0.15,Tt=m*0.15;P.append("path").attr("class","cynefinConfusion").attr("d",vt(c/2,m/2,kt,Tt)).attr("fill",Y.confusion).attr("fill-opacity",0.5);let ft=P.append("g").attr("class","cynefin-labels");for(let d of st){let s=et[d];ft.append("text").attr("class","cynefinDomainLabel").attr("x",s.cx).attr("y",h?s.cy-30:s.cy).attr("text-anchor","middle").attr("dominant-baseline","middle").text(d.charAt(0).toUpperCase()+d.slice(1))}if(ft.append("text").attr("class","cynefinDomainLabel").attr("x",c/2).attr("y",h?m/2-10:m/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text("Confusion"),h){let d=P.append("g").attr("class","cynefin-subtitles");for(let s of st){let g=et[s],u=gt[s];d.append("text").attr("class","cynefinSubtitle").attr("x",g.cx).attr("y",g.cy-10).attr("text-anchor","middle").attr("dominant-baseline","middle").text(u.model),d.append("text").attr("class","cynefinSubtitle").attr("x",g.cx).attr("y",g.cy+5).attr("text-anchor","middle").attr("dominant-baseline","middle").text(u.practice)}d.append("text").attr("class","cynefinSubtitle").attr("x",c/2).attr("y",m/2+8).attr("text-anchor","middle").attr("dominant-baseline","middle").text(gt.confusion.practice)}let mt=P.append("g").attr("class","cynefin-items"),I=26,pt=10,At=["complex","complicated","chaotic","clear","confusion"];for(let d of At){let s=p.get(d);if(!s||s.items.length===0)continue;let g=et[d],u=d==="confusion",O=s.items,X=0;if(u&&s.items.length>lt)X=s.items.length-lt,O=s.items.slice(0,lt);let W;if(u){let w=h?22:14;W=g.cy+w}else W=g.cy+(h?25:15);if([...O].forEach((w,_)=>{let k=W+_*(I+4),G=mt.append("g"),q=G.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",I/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(w.label),v=w.label.length*7,b=q.node();if(b&&typeof b.getBBox==="function"){let rt=b.getBBox();if(rt.width>0)v=rt.width}let B=v+pt*2,U=g.cx-B/2;G.attr("transform",`translate(${U}, ${k})`),G.insert("rect","text").attr("class","cynefinItem").attr("x",0).attr("y",0).attr("width",B).attr("height",I).attr("rx",4).attr("ry",4).attr("fill",Y[d]).attr("fill-opacity",0.95),q.attr("x",B/2).attr("y",I/2)}),X>0){let w=W+O.length*(I+4),_=`+${X} more`,k=mt.append("g"),G=k.append("text").attr("class","cynefinItemText").attr("x",0).attr("y",I/2).attr("text-anchor","middle").attr("dominant-baseline","central").text(_),q=_.length*7,v=G.node();if(v&&typeof v.getBBox==="function"){let U=v.getBBox();if(U.width>0)q=U.width}let b=q+pt*2,B=g.cx-b/2;k.attr("transform",`translate(${B}, ${w})`),k.insert("rect","text").attr("class","cynefinItemOverflow").attr("x",0).attr("y",0).attr("width",b).attr("height",I).attr("rx",4).attr("ry",4).attr("fill",Y[d]).attr("fill-opacity",0.6),G.attr("x",b/2).attr("y",I/2)}}if(at.length>0){let d=z.select("defs").empty()?z.append("defs"):z.select("defs"),s=`cynefin-arrow-${n}`;d.append("marker").attr("id",s).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("class","cynefinArrowHead");let g=P.append("g").attr("class","cynefin-arrows");at.forEach((u)=>{let O=et[u.from],X=et[u.to];if(!O||!X)return;if(u.from===u.to){a.warn(`Cynefin renderer: skipping self-loop on domain "${u.from}"`);return}let{cx:W,cy:w}=O,{cx:_,cy:k}=X,G=(W+_)/2,q=(w+k)/2,v=_-W,b=k-w,B=Math.sqrt(v*v+b*b),U=B*0.15,rt=-b/B,Bt=v/B,yt=G+rt*U,ut=q+Bt*U;if(g.append("path").attr("class","cynefinArrowLine").attr("d",`M${W},${w} Q${yt},${ut} ${_},${k}`).attr("fill","none").attr("marker-end",`url(#${s})`),u.label)g.append("text").attr("class","cynefinArrowLabel").attr("x",yt).attr("y",ut-6).attr("text-anchor","middle").attr("dominant-baseline","auto").text(u.label)})}if(Q)P.append("text").attr("class","cynefinTitle").attr("x",c/2).attr("y",-D/2).attr("text-anchor","middle").attr("dominant-baseline","middle").text(Q)},"draw"),_t={draw:Vt},Et=t(()=>{let e=we(),n=x();return j(e,n.themeVariables).cynefin},"getCynefinTheme"),Ht=t(()=>{let e=Et();return`
|
|
2
2
|
.cynefinDomain {
|
|
3
3
|
stroke: none;
|
|
4
4
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{g,o,v,i,r,f,e,n,y,st}from"./chunk-3k9h7a73.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),d=c%60;return d>0?`${a}m ${d}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),d=c%60;return d>0?`${a}h ${d}m`:`${a}h`}let u=Math.floor(t/3600000),b=Math.floor(u/24),p=u%24;return p>0?`${b}d ${p}h`:`${b}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let b=10**-u/100;if(t<b)return`<${(b*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),b=u[1],p=u[2];if(b!==void 0&&p!==void 0)return`${b}/${p}`;return t}function Z(t){let u=t.split("-"),b=u[0],p=u[1],c=u[2];if(b===void 0||p===void 0||c===void 0)return t;let a=Number(b),d=Number(p)-1,h=Number(c),w=new Date(Date.UTC(a,d,h)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let b=Math.max(0,u-t);if(b<60000)return"刚刚";if(b<3600000)return`${Math.max(1,Math.floor(b/60000))} 分钟前`;if(b<86400000)return`${Math.max(1,Math.floor(b/3600000))} 小时前`;if(b<2592000000)return`${Math.max(1,Math.floor(b/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),d=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${d}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:b,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=a.projectID??V,h=b===d,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(h?null:d),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:h?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},d)})})}function re(t){let{models:u}=t,{ModelIcon:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(b,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:b,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),d=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",h=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(b,{tone:d,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:h.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:b}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let d=c>0?Math.max(1,a.totalTokens/c*100):0,h=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>b(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(st,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:d}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:h}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:b,SettingGroup:p,style:c}=y(),{daily:a}=t,[d,h]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(d==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(d==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,d]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(d==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(d==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,d]),m=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(b,{value:d,onChange:(s)=>h(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[d==="tokens"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),d==="duration"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),d==="activity"&&n(f,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(d==="duration")l=s.activeDurationMs;else if(d==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[d==="tokens"&&n(f,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),d==="duration"&&n(f,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),d==="activity"&&n(f,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:m.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(f,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:b}=y(),{daily:p,hourly:c}=t,[a,d]=r(null),h=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=h[0];for(let x of h)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[h]),C=v(()=>h.reduce((l,x)=>l+x.totalTokens,0),[h]),D=v(()=>Math.max(1,...h.map((l)=>l.totalTokens)),[h]),F=v(()=>{if(C<=0)return 0;return h.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[h,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),m=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?h[a]:w;return n(b,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",m,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>d(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:h.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
|
|
1
|
+
import{h,o,v,i,r,m,e,n,y,lt}from"./chunk-ty2rmwda.js";var V="__chat__";function M(t){if(!Number.isFinite(t)||t<=0)return"0";if(t<1000)return Math.round(t).toString();if(t<1e6)return`${(t/1000).toFixed(1)}K`;if(t<1e9)return`${(t/1e6).toFixed(2)}M`;return`${(t/1e9).toFixed(2)}B`}function L(t){let u=Number.isFinite(t)?Math.max(0,t):0;return Math.round(u).toLocaleString("en-US")}function P(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.floor(t/1000)}s`;if(t<3600000){let c=Math.floor(t/1000),a=Math.floor(c/60),f=c%60;return f>0?`${a}m ${f}s`:`${a}m`}if(t<259200000){let c=Math.floor(t/60000),a=Math.floor(c/60),f=c%60;return f>0?`${a}h ${f}m`:`${a}h`}let u=Math.floor(t/3600000),g=Math.floor(u/24),p=u%24;return p>0?`${g}d ${p}h`:`${g}d`}function ae(t){if(!Number.isFinite(t)||t<=0)return"0s";if(t<1000)return"<1s";if(t<60000)return`${Math.round(t/1000)}s`;if(t<3600000)return`${Math.round(t/60000)}m`;if(t<86400000){let p=t/3600000;return`${p>=10?Math.round(p).toString():p.toFixed(1).replace(/\.0$/,"")}h`}let u=t/86400000;return`${u>=10?Math.round(u).toString():u.toFixed(1).replace(/\.0$/,"")}d`}function B(t,u=1){if(!Number.isFinite(t)||t<=0)return"0%";let g=10**-u/100;if(t<g)return`<${(g*100).toFixed(u)}%`;return`${(t*100).toFixed(u)}%`}function Q(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${Math.round(t)} B`;if(t<1048576)return`${(t/1024).toFixed(1)} KB`;if(t<1073741824)return`${(t/1048576).toFixed(2)} MB`;return`${(t/1073741824).toFixed(2)} GB`}function W(t){let u=t.split("-"),g=u[1],p=u[2];if(g!==void 0&&p!==void 0)return`${g}/${p}`;return t}function Z(t){let u=t.split("-"),g=u[0],p=u[1],c=u[2];if(g===void 0||p===void 0||c===void 0)return t;let a=Number(g),f=Number(p)-1,b=Number(c),w=new Date(Date.UTC(a,f,b)),C=["周日","周一","周二","周三","周四","周五","周六"],D=w.getUTCDay(),F=C[D]??"";return`${t} ${F}`}function se(t,u=Date.now()){if(t===null||t===void 0||!Number.isFinite(t)||t<=0)return"从未";let g=Math.max(0,u-t);if(g<60000)return"刚刚";if(g<3600000)return`${Math.max(1,Math.floor(g/60000))} 分钟前`;if(g<86400000)return`${Math.max(1,Math.floor(g/3600000))} 小时前`;if(g<2592000000)return`${Math.max(1,Math.floor(g/86400000))} 天前`;let p=new Date(t),c=p.getFullYear(),a=String(p.getMonth()+1).padStart(2,"0"),f=String(p.getDate()).padStart(2,"0");return`${c}-${a}-${f}`}function K(t){return e("div",{className:"h-1.5 w-full overflow-hidden rounded-full bg-raised",children:e("div",{className:"h-full rounded-full bg-accent transition-all duration-300",style:{width:`${t.percent}%`}})})}function Y(t){return e("div",{className:"flex flex-wrap items-center justify-between gap-x-4 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:t.children})}function G(t){return e("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1",children:t.children})}function J(t){return n(G,{children:[n("span",{children:["输入 ",e("span",{className:"text-ink",children:M(t.stat.inputTokens)})]}),n("span",{children:["输出 ",e("span",{className:"text-ink",children:M(t.stat.outputTokens)})]}),n("span",{children:["缓存读 ",e("span",{className:"text-ink",children:M(t.stat.cacheReadTokens)}),t.cacheHitRate!==void 0&&n("span",{className:"text-faint",children:[" (",B(t.cacheHitRate),")"]})]})]})}function oe(t){let{projects:u,selectedProjectID:g,onSelectProject:p}=t,{style:c}=y();if(u.length===0)return e("div",{className:c("surface.empty"),children:"暂无项目统计数据"});return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=a.projectID??V,b=g===f,w=Math.max(a.tokenShare>0?1:0,a.tokenShare*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate",children:a.name}),e("span",{className:c("control.badge","font-mono truncate max-w-[240px]"),title:a.directory||"未绑定项目目录",children:a.directory||"独立会话"}),e("button",{type:"button",onClick:()=>p(b?null:f),className:"rounded px-1.5 py-0.5 text-[11px] text-accent hover:bg-accent/10 transition-colors cursor-pointer shrink-0",children:b?"取消筛选":"筛选"})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),n("span",{className:"text-[11px] text-faint",children:["(",B(a.tokenShare),")"]})]})]}),e(K,{percent:w}),n(Y,{children:[e(J,{stat:a,cacheHitRate:a.cacheHitRate}),n(G,{children:[n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.sessionCount.toLocaleString()})," 会话"]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:a.toolCalls.toLocaleString()})," 次"]})]})]})]},f)})})}function re(t){let{models:u}=t,{ModelIcon:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无模型调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100);return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e(g,{modelID:c.model,className:"size-4 shrink-0"}),e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.shortName}),e("span",{className:p("control.badge","font-mono shrink-0"),children:c.provider})]}),n("div",{className:"flex items-baseline gap-2.5 font-mono tabular-nums shrink-0",children:[c.avgTps!==null&&n("span",{className:"text-[11px] text-dim",children:[c.avgTps.toFixed(1)," tok/s"]}),n("span",{className:"text-xs font-medium text-ink",title:L(c.totalTokens),children:[M(c.totalTokens)," ",n("span",{className:"text-[11px] font-normal text-faint",children:["(",B(c.share),")"]})]})]})]}),e(K,{percent:a}),n(Y,{children:[e(J,{stat:c,cacheHitRate:c.cacheHitRate}),n(G,{children:[n("span",{children:[e("span",{className:"text-ink",children:c.turns.toLocaleString()})," 轮",c.errors>0?n("span",{className:"text-danger",children:[" (",c.errors," 错)"]}):null]}),n("span",{children:["工具 ",e("span",{className:"text-ink",children:c.toolCalls.toLocaleString()})," 次"]}),c.generationMs>0&&n("span",{children:["推理 ",e("span",{className:"text-ink",children:ae(c.generationMs)})]})]})]})]},c.model)})})}function ie(t){let{tools:u}=t,{StatusChip:g,style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无工具调用数据"});return e("div",{className:"divide-y divide-line",children:u.map((c)=>{let a=Math.max(c.share>0?1:0,c.share*100),f=c.successRate>=0.95?"success":c.successRate>=0.8?"warning":"danger",b=Math.max(0,c.calls-c.errors),w=c.calls>0?Math.round(c.outputBytes/c.calls):0;return n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 items-center gap-2",children:[e("span",{className:"font-mono text-sm font-medium text-ink truncate",children:c.name}),n(g,{tone:f,children:["成功率 ",B(c.successRate)]})]}),n("div",{className:"flex items-baseline gap-1.5 font-mono tabular-nums shrink-0",children:[n("span",{className:"text-xs font-medium text-ink",children:[c.calls.toLocaleString()," 次"]}),n("span",{className:"text-[11px] text-faint",children:["(",B(c.share),")"]})]})]}),e(K,{percent:a}),n(Y,{children:[n(G,{children:[n("span",{children:["成功 ",e("span",{className:"text-ink",children:b.toLocaleString()})," 次"]}),n("span",{children:["失败 ",e("span",{className:c.errors>0?"text-danger":"text-ink",children:c.errors.toLocaleString()})," 次"]})]}),n(G,{children:[n("span",{children:["累计输出 ",e("span",{className:"text-ink",children:Q(c.outputBytes)})]}),n("span",{children:["单次均值 ",e("span",{className:"text-ink",children:Q(w)})]})]})]})]},c.name)})})}function le(t){let{sessions:u,onOpenSession:g}=t,{style:p}=y();if(u.length===0)return e("div",{className:p("surface.empty"),children:"暂无高消耗会话记录"});let c=Math.max(1,...u.map((a)=>a.totalTokens));return e("div",{className:"divide-y divide-line",children:u.map((a)=>{let f=c>0?Math.max(1,a.totalTokens/c*100):0,b=a.model.split("/").pop()??a.model;return n("button",{type:"button",onClick:()=>g(a.id),className:"group block w-full p-4 text-left space-y-2.5 hover:bg-raised/40 transition-colors cursor-pointer",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[e("span",{className:"font-medium text-sm text-ink truncate group-hover:text-accent transition-colors",children:a.title.trim()||"新会话"}),e("span",{className:p("control.badge","font-mono truncate max-w-[140px] shrink-0"),title:a.projectName,children:a.projectName}),a.kind==="sub"&&e("span",{className:"rounded bg-accent/15 px-1.5 py-0.5 text-[10.5px] text-accent shrink-0",children:"子代理"}),a.archivedAt!==null&&e("span",{className:p("control.badge","shrink-0"),children:"已归档"})]}),n("div",{className:"flex items-center gap-1.5 font-mono tabular-nums shrink-0",children:[e("span",{className:"text-xs font-medium text-ink",title:L(a.totalTokens),children:M(a.totalTokens)}),e(lt,{className:"size-3.5 text-faint group-hover:text-ink group-hover:translate-x-0.5 transition-all"})]})]}),e(K,{percent:f}),n(Y,{children:[e(J,{stat:a}),n(G,{children:[e("span",{className:"text-ink",children:b}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(a.activeDurationMs)})]}),n("span",{children:[e("span",{className:"text-ink",children:a.assistantTurns})," 轮"]}),e("span",{className:"text-faint",children:se(a.updated)})]})]})]},a.id)})})}var ce=[{value:"tokens",label:"Token 用量"},{value:"duration",label:"活跃耗时"},{value:"activity",label:"交互轮次"}];function ue(t){let{cn:u,Segmented:g,SettingGroup:p,style:c}=y(),{daily:a}=t,[f,b]=r("tokens"),[w,C]=r(null),D=v(()=>a.some((s)=>s.totalTokens>0||s.activeDurationMs>0||s.runs>0),[a]),F=v(()=>{if(a.length===0)return{totalText:"0",avgText:"0",peakDate:"—",peakValueText:"0"};if(f==="tokens"){let S=a.reduce((_,A)=>_+A.totalTokens,0),R=a.filter((_)=>_.totalTokens>0).length,N=a[0];for(let _ of a)if(!N||_.totalTokens>N.totalTokens)N=_;return{totalText:M(S),totalFullText:L(S),avgText:R>0?M(Math.round(S/R)):"0",peakDate:N&&N.totalTokens>0?W(N.date):"—",peakValueText:N&&N.totalTokens>0?M(N.totalTokens):"0"}}if(f==="duration"){let S=a.reduce((_,A)=>_+A.activeDurationMs,0),R=a.filter((_)=>_.activeDurationMs>0).length,N=a[0];for(let _ of a)if(!N||_.activeDurationMs>N.activeDurationMs)N=_;return{totalText:P(S),totalFullText:P(S),avgText:R>0?P(Math.round(S/R)):"0s",peakDate:N&&N.activeDurationMs>0?W(N.date):"—",peakValueText:N&&N.activeDurationMs>0?P(N.activeDurationMs):"0s"}}let s=a.reduce((S,R)=>S+R.assistantTurns,0),l=a.reduce((S,R)=>S+R.userMessages,0),x=s+l,T=a.filter((S)=>S.assistantTurns>0||S.userMessages>0).length,k=a[0];for(let S of a){let R=k?k.assistantTurns+k.userMessages:0;if(!k||S.assistantTurns+S.userMessages>R)k=S}let H=k?k.assistantTurns+k.userMessages:0;return{totalText:`${x.toLocaleString()} 轮`,totalFullText:`助手 ${s.toLocaleString()} 轮 · 用户 ${l.toLocaleString()} 问`,avgText:T>0?`${(x/T).toFixed(1)} 轮/天`:"0 轮/天",peakDate:k&&H>0?W(k.date):"—",peakValueText:k&&H>0?`${H.toLocaleString()} 轮`:"0 轮"}},[a,f]),j=v(()=>{if(w){let s=a.find((l)=>l.date===w);if(s)return s}for(let s=a.length-1;s>=0;s--){let l=a[s];if(l&&(l.totalTokens>0||l.activeDurationMs>0||l.runs>0))return l}return a[a.length-1]},[a,w]),z=v(()=>{if(f==="tokens")return Math.max(1,...a.map((s)=>s.totalTokens));if(f==="duration")return Math.max(1000,...a.map((s)=>s.activeDurationMs));return Math.max(1,...a.map((s)=>s.assistantTurns+s.userMessages))},[a,f]),d=v(()=>{if(a.length<=7)return a.map((x)=>x.date);let s=6,l=[];for(let x=0;x<s;x++){let T=Math.round(x*(a.length-1)/(s-1)),k=a[T];if(k)l.push(k.date)}return l},[a]);if(!D)return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:e("div",{className:c("surface.empty"),children:"当前时间范围内暂无活跃数据"})});return e(p,{title:"每日趋势",action:e(g,{value:f,onChange:(s)=>b(s),options:ce}),children:n("div",{className:"p-4 space-y-4",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 font-mono text-dim tabular-nums",children:[n("span",{children:["汇总 ",e("span",{className:"text-ink",children:F.totalText})]}),n("span",{children:["日均 ",e("span",{className:"text-ink",children:F.avgText})]}),n("span",{children:["峰值 ",e("span",{className:"text-ink",children:F.peakValueText}),F.peakDate!=="—"?n("span",{className:"text-faint",children:[" (",F.peakDate,")"]}):null]})]}),n("div",{className:"flex items-center gap-3 text-[11px] text-dim",children:[f==="tokens"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent/40"}),"缓存读"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"输入"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"输出"]})]}),f==="duration"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"工作调度"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"模型推理"]})]}),f==="activity"&&n(m,{children:[n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-accent"}),"助手回复"]}),n("span",{className:"inline-flex items-center gap-1.5",children:[e("span",{className:"size-2 rounded-full bg-success"}),"用户提问"]})]})]})]}),n("div",{className:"relative h-44 w-full pt-1",children:[n("div",{className:"absolute inset-0 flex flex-col justify-between pointer-events-none pb-5 text-[10px] text-faint/60",children:[e("div",{className:"border-b border-line/40 w-full"}),e("div",{className:"border-b border-line/30 w-full"}),e("div",{className:"border-b border-line/40 w-full"})]}),n("section",{"aria-label":"每日趋势柱状序列",className:"relative h-full flex flex-col justify-between",onMouseLeave:()=>C(null),children:[e("div",{className:"flex-1 flex items-end gap-1 sm:gap-1.5 pb-2",children:a.map((s)=>{let l=s.totalTokens;if(f==="duration")l=s.activeDurationMs;else if(f==="activity")l=s.assistantTurns+s.userMessages;let x=l<=0,T=x?0:Math.max(3,Math.min(100,l/z*100)),k=j?.date===s.date;return n("button",{type:"button","aria-label":`${s.date} 统计数据`,className:"flex-1 h-full flex flex-col justify-end items-center group cursor-pointer relative min-w-0 bg-transparent p-0 border-0 focus:outline-hidden",onMouseEnter:()=>C(s.date),onFocus:()=>C(s.date),onClick:()=>C(s.date),children:[e("div",{className:u("absolute inset-y-0 w-full rounded-xs transition-colors pointer-events-none",k?"bg-accent/10":"group-hover:bg-raised/60")}),x?e("div",{className:"h-1 w-full max-w-[24px] rounded-full bg-raised group-hover:bg-dim/30"}):n("div",{className:"w-full max-w-[24px] rounded-t-xs overflow-hidden flex flex-col justify-end transition-all duration-150",style:{height:`${T}%`},children:[f==="tokens"&&n(m,{children:[s.outputTokens>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.outputTokens/s.totalTokens*100}%`}}),s.inputTokens+s.cacheWriteTokens>0&&e("div",{className:"bg-accent transition-all duration-200",style:{height:`${(s.inputTokens+s.cacheWriteTokens)/s.totalTokens*100}%`}}),s.cacheReadTokens>0&&e("div",{className:"bg-accent/40 transition-all duration-200",style:{height:`${s.cacheReadTokens/s.totalTokens*100}%`}})]}),f==="duration"&&n(m,{children:[s.generationMs>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${Math.min(100,s.generationMs/Math.max(1,s.activeDurationMs)*100)}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]}),f==="activity"&&n(m,{children:[s.userMessages>0&&e("div",{className:"bg-success transition-all duration-200",style:{height:`${s.userMessages/Math.max(1,s.assistantTurns+s.userMessages)*100}%`}}),e("div",{className:"bg-accent flex-1 transition-all duration-200"})]})]}),k&&e("div",{className:"absolute -bottom-1 size-1 rounded-full bg-accent"})]},s.date)})}),e("div",{className:u("flex items-center pt-1.5 text-[10px] text-faint font-mono tabular-nums",a.length<=7?"gap-1 sm:gap-1.5":"justify-between"),children:d.map((s)=>e("div",{className:u("whitespace-nowrap",a.length<=7&&"flex-1 text-center"),children:W(s)},s))})]})]}),e("div",{className:"flex flex-wrap items-center justify-between gap-2 border-t border-line pt-3 font-mono text-xs tabular-nums",children:j?n(m,{children:[e("span",{className:"text-ink",children:Z(j.date)}),n("div",{className:"flex flex-wrap items-center gap-x-3.5 gap-y-1 text-dim",children:[n("span",{children:["Token ",e("span",{className:"text-ink",children:M(j.totalTokens)})]}),n("span",{children:["耗时 ",e("span",{className:"text-ink",children:P(j.activeDurationMs)})]}),n("span",{children:["交互 ",n("span",{className:"text-ink",children:[j.assistantTurns+j.userMessages," 轮"]})]}),n("span",{children:["工具 ",n("span",{className:"text-ink",children:[j.toolCalls," 次"]})]})]})]}):e("span",{className:"font-sans text-faint",children:"悬停柱状图查看单日明细"})})]})})}function pe(t){let{cn:u,SettingGroup:g}=y(),{daily:p,hourly:c}=t,[a,f]=r(null),b=v(()=>{let l=new Map;for(let T of c)l.set(T.hour,T);let x=[];for(let T=0;T<24;T++){let k=l.get(T);if(k)x.push(k);else x.push({hour:T,totalTokens:0,activeDurationMs:0,userMessages:0,assistantTurns:0,runs:0})}return x},[c]),w=v(()=>{let l=b[0];for(let x of b)if(!l||x.totalTokens>l.totalTokens)l=x;return l&&l.totalTokens>0?l:null},[b]),C=v(()=>b.reduce((l,x)=>l+x.totalTokens,0),[b]),D=v(()=>Math.max(1,...b.map((l)=>l.totalTokens)),[b]),F=v(()=>{if(C<=0)return 0;return b.filter((x)=>x.hour>=8&&x.hour<20).reduce((x,T)=>x+T.totalTokens,0)/C},[b,C]),j=v(()=>Math.max(1,...p.map((l)=>l.totalTokens)),[p]),z=v(()=>{let l=0,x=0;for(let T of p)if(T.totalTokens>0||T.activeDurationMs>0||T.runs>0){if(x++,x>l)l=x}else x=0;return l},[p]),d=v(()=>p.filter((l)=>l.totalTokens>0||l.activeDurationMs>0||l.runs>0).length,[p]),s=a!==null?b[a]:w;return n(g,{title:"活跃时段与热力",action:n("div",{className:"flex items-center gap-3 font-mono text-xs text-faint tabular-nums",children:[n("span",{children:["日间占比 ",B(F)]}),n("span",{children:["连续活跃 ",z," 天"]}),n("span",{children:["活跃 ",d,"/",p.length," 天"]})]}),children:[n("div",{className:"p-4 space-y-3",children:[n("div",{className:"flex flex-wrap items-center justify-between gap-2 text-xs",children:[e("span",{className:"text-dim",children:"24 小时分布"}),s?n("div",{className:"flex items-center gap-3 font-mono text-dim tabular-nums",children:[n("span",{className:"text-ink",children:[a!==null?"时段 ":"高峰 ",String(s.hour).padStart(2,"0"),":00 -"," ",String((s.hour+1)%24).padStart(2,"0"),":00"]}),e("span",{className:"text-ink",children:M(s.totalTokens)}),s.activeDurationMs>0&&e("span",{children:P(s.activeDurationMs)})]}):e("span",{className:"text-faint",children:"暂无时段分布"})]}),n("section",{"aria-label":"24 小时活跃分布序列",className:"h-28 w-full flex flex-col justify-between pt-1",onMouseLeave:()=>f(null),children:[e("div",{className:"flex-1 flex items-end gap-1.5 pb-1.5",children:b.map((l)=>{let x=w?.hour===l.hour,T=a===l.hour,k=l.totalTokens>0?Math.max(6,l.totalTokens/D*100):0,H=`${String(l.hour).padStart(2,"0")}:00 - ${String((l.hour+1)%24).padStart(2,"0")}:00
|
|
2
2
|
消耗: ${L(l.totalTokens)} Token
|
|
3
3
|
耗时: ${P(l.activeDurationMs)}
|
|
4
|
-
助手轮次: ${l.assistantTurns} 轮`;return e("button",{type:"button","aria-label":`${String(l.hour).padStart(2,"0")}:00 时段统计`,className:"flex-1 h-full flex flex-col justify-end items-center group relative cursor-pointer bg-transparent p-0 border-0 focus:outline-hidden",title:H,onMouseEnter:()=>
|
|
4
|
+
助手轮次: ${l.assistantTurns} 轮`;return e("button",{type:"button","aria-label":`${String(l.hour).padStart(2,"0")}:00 时段统计`,className:"flex-1 h-full flex flex-col justify-end items-center group relative cursor-pointer bg-transparent p-0 border-0 focus:outline-hidden",title:H,onMouseEnter:()=>f(l.hour),onFocus:()=>f(l.hour),onClick:()=>f(l.hour),children:k>0?e("div",{className:u("w-full max-w-[20px] rounded-t-xs transition-all duration-200",x||T?"bg-accent":"bg-accent/55 group-hover:bg-accent"),style:{height:`${k}%`}}):e("div",{className:"h-1 w-full max-w-[20px] rounded-full bg-raised group-hover:bg-dim/30"})},l.hour)})}),n("div",{className:"flex justify-between items-center text-[10px] text-faint font-mono pt-1.5 border-t border-line/40",children:[e("span",{children:"00:00"}),e("span",{children:"04:00"}),e("span",{children:"08:00"}),e("span",{children:"12:00"}),e("span",{children:"16:00"}),e("span",{children:"20:00"}),e("span",{children:"23:00"})]})]})]}),n("div",{className:"p-4 space-y-2.5",children:[n("div",{className:"text-xs text-dim",children:["自然日热力 (",p.length," 天)"]}),e("div",{className:"flex flex-wrap items-center gap-1.5",children:p.map((l)=>{let x="bg-raised";if(l.totalTokens>0){let k=l.totalTokens/j;if(k<=0.33)x="bg-accent/30";else if(k<=0.66)x="bg-accent/60";else x="bg-accent"}let T=`${Z(l.date)}
|
|
5
5
|
消耗: ${L(l.totalTokens)} Token
|
|
6
6
|
耗时: ${P(l.activeDurationMs)}
|
|
7
|
-
助手轮次: ${l.assistantTurns} 轮`;return e("div",{className:u("size-3.5 rounded-xs transition-transform hover:scale-125 cursor-pointer",x),title:T},l.date)})})]})]})}var xe=[{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"},{value:"90d",label:"近 90 天"},{value:"all",label:"全部"}],q=new Map,me=[];function X(t,u){return`${t}:${u??"all"}`}function Le(t){let{connection:u,onOpen:
|
|
7
|
+
助手轮次: ${l.assistantTurns} 轮`;return e("div",{className:u("size-3.5 rounded-xs transition-transform hover:scale-125 cursor-pointer",x),title:T},l.date)})})]})]})}var xe=[{value:"7d",label:"近 7 天"},{value:"30d",label:"近 30 天"},{value:"90d",label:"近 90 天"},{value:"all",label:"全部"}],q=new Map,me=[];function X(t,u){return`${t}:${u??"all"}`}function Le(t){let{connection:u,onOpen:g}=t,{Button:p,PageLayout:c,Segmented:a,SettingGroup:f,style:b}=y(),[w,C]=r("30d"),[D,F]=r(null),[j,z]=r("projects"),[d,s]=r(()=>q.get(X("30d",null))??null),[l,x]=r(()=>!q.has(X("30d",null))),[T,k]=r(null),[H,S]=r(()=>me),R=i(0),N=h(async()=>{let A=++R.current,O=X(w,D),ee=q.get(O);if(ee)s(ee);x(!0);try{let E=new URLSearchParams({range:w,tzOffset:String(new Date().getTimezoneOffset())});if(D)E.set("projectID",D);let U=await u.request(`/api/stats?${E.toString()}`);if(A!==R.current)return;if(q.set(O,U),s(U),k(null),U.projects)S((de)=>{let te=new Map(de.map((I)=>[I.id,I.name]));for(let I of U.projects)if(I.projectID)te.set(I.projectID,I.name);let ne=Array.from(te.entries()).map(([I,fe])=>({id:I,name:fe}));return me=ne,ne})}catch(E){if(A===R.current)k(E instanceof Error?E.message:"加载统计数据失败")}finally{if(A===R.current)x(!1)}},[u,w,D]);o(()=>(N(),()=>{R.current++}),[N]);let _=v(()=>{if(!D)return null;if(D===V)return"独立聊天";return(H.find((O)=>O.id===D)??d?.projects.find((O)=>O.projectID===D))?.name??"指定项目"},[D,H,d]);return n(c,{title:_?n(m,{children:["统计 ",n("span",{className:"text-dim",children:["· ",_]})]}):"统计",description:"按项目、模型与工具统计活跃耗时与 Token 消耗。",actions:n(m,{children:[D&&e(p,{size:"sm",variant:"ghost",onClick:()=>F(null),children:"返回全部"}),e(a,{value:w,onChange:C,options:xe})]}),children:[T&&n("div",{className:"mb-4 flex items-center justify-between rounded-lg bg-danger/10 px-3 py-2 text-xs text-danger",children:[e("span",{children:T}),e(p,{size:"sm",variant:"ghost",onClick:()=>{N()},className:"text-danger hover:text-danger",children:"重试"})]}),l&&!d?e("div",{className:"flex justify-center py-12 text-xs text-faint",children:"正在加载统计…"}):!d?e("div",{className:b("surface.card","p-12 text-center text-sm text-dim"),children:"暂无统计数据"}):n("div",{className:"space-y-8",children:[e(f,{title:"核心总览",unboxed:!0,children:n("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"总 Token 消耗"}),n("span",{className:"font-mono tabular-nums",children:["缓存命中 ",B(d.overview.cacheHitRate)]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",title:`${L(d.overview.totalTokens)} Token`,children:M(d.overview.totalTokens)}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:["输入 ",M(d.overview.inputTokens)]}),n("span",{children:["输出 ",M(d.overview.outputTokens)]}),n("span",{children:["缓存读 ",M(d.overview.cacheReadTokens)]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"活跃工作耗时"}),n("span",{className:"font-mono tabular-nums",children:["日均"," ",d.overview.activeDays>0?P(d.overview.activeDurationMs/d.overview.activeDays):"0s"]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:P(d.overview.activeDurationMs)}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:["模型推理 ",P(d.overview.generationMs)]}),n("span",{children:["并发累计 ",P(d.overview.cumulativeRunDurationMs)]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"会话与工作流"}),n("span",{className:"font-mono tabular-nums",children:[d.overview.activeProjects,"/",d.overview.totalProjects," 活跃项目"]})]}),n("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:[d.overview.sessionCount.toLocaleString()," 个会话"]}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:[d.overview.mainSessionCount," 主会话 / ",d.overview.subSessionCount," 子代理"]}),n("span",{children:[d.overview.userMessages," 提问 / ",d.overview.assistantTurns," 回复"]})]})]}),n("div",{className:b("surface.card","p-4"),children:[n("div",{className:"flex items-center justify-between gap-2 text-xs text-faint",children:[e("span",{children:"吞吐效率与调用"}),n("span",{className:"font-mono tabular-nums",children:[d.overview.compactions," 次折叠"]})]}),e("div",{className:"mt-1.5 font-mono text-xl font-semibold tracking-tight text-ink tabular-nums",children:d.overview.avgTps!==null?`${d.overview.avgTps.toFixed(1)} tok/s`:`${d.overview.toolCalls.toLocaleString()} 次调用`}),n("div",{className:"mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 font-mono text-[11px] text-dim tabular-nums",children:[n("span",{children:[d.overview.toolCalls.toLocaleString()," 次工具调用"]}),n("span",{children:[d.overview.runCount.toLocaleString()," 次运行"]})]})]})]})}),e(ue,{daily:d.daily}),e(pe,{daily:d.daily,hourly:d.hourly}),e(f,{title:"分类明细",action:e(a,{value:j,onChange:z,options:[{value:"projects",label:`项目消耗 (${d.projects.length})`},{value:"models",label:`模型分析 (${d.models.length})`},{value:"tools",label:`工具调用 (${d.tools.length})`},{value:"sessions",label:`高消耗会话 (${d.topSessions.length})`}]}),children:n("div",{className:"animate-fade",children:[j==="projects"&&e(oe,{projects:d.projects,selectedProjectID:D,onSelectProject:F,onOpenSession:g}),j==="models"&&e(re,{models:d.models}),j==="tools"&&e(ie,{tools:d.tools}),j==="sessions"&&e(le,{sessions:d.topSessions,onOpenSession:g})]},j)})]})]})}export{Le as StatsPage};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{r,
|
|
2
|
-
export{
|
|
1
|
+
import{r,m,e,n,y,s,te,nn,K}from"./chunk-ty2rmwda.js";var g=[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M7 16c.5-2 1.5-7 4-7 2 0 2 3 4 3 2.5 0 4.5-5 5-7",key:"lw07rv"}]],d=s("chart-spline",g);function ia(t){let i=y();i.useTheme();let[u,c]=r("preview"),o=t.streaming&&!t.rendered,l=!t.streaming&&!t.rendered&&Boolean(t.error),a=u==="code"||o;return n(i.Panel,{"aria-label":t.title,"data-render-pending":t.pending&&!l?"true":void 0,className:"group/graph relative my-4 font-sans not-italic first:mt-0 last:mb-0",children:[e("div",{role:"toolbar","aria-label":`${t.title}操作`,className:o?"absolute top-2 right-2 z-10 flex items-center":i.style("surface.toolbarFloating","absolute top-2 right-2 z-10 opacity-0 transition-opacity duration-150 group-hover/graph:opacity-100 focus-within:opacity-100 [@media(hover:none)]:opacity-70"),children:o?n("span",{className:i.style("control.badge","gap-1.5 rounded-full px-2 py-0.5 text-[11px]"),children:[e(K,{className:"size-3 animate-spin"}),"生成",t.title]}):n(m,{children:[e("button",{type:"button","aria-label":a?"查看图表":"查看代码",title:a?"查看图表":"查看代码",onClick:()=>c(a?"preview":"code"),className:"flex size-6 items-center justify-center rounded-md text-dim hover:bg-raised hover:text-ink [&_svg]:size-3.5",children:a?e(d,{}):e(nn,{})}),e(i.CopyButton,{text:t.code,size:"icon-sm",label:"复制代码"})]})}),a&&e(i.Code,{code:t.code,lang:t.codeLang,className:"px-4 py-3"}),l&&!a&&n("div",{role:"alert",className:"flex flex-col items-center gap-2 px-4 py-8 text-center",children:[e(te,{className:"size-5 text-warning"}),e("p",{className:"max-w-full text-xs break-words text-dim",children:t.error}),e("button",{type:"button",onClick:()=>c("code"),className:"text-xs text-accent-strong underline underline-offset-2",children:"查看代码"})]}),e("div",{hidden:a||l,children:t.children})]})}
|
|
2
|
+
export{ia};
|