@kimiclaw/cli 1.0.44 → 1.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +17 -19
  2. package/package.json +9 -9
  3. package/web/dist/assets/{AssistantsView-Y4TXobGE.js → AssistantsView-Y3nFezhd.js} +1 -1
  4. package/web/dist/assets/AutomationView-bf7_zU_p.js +4 -0
  5. package/web/dist/assets/Button-B43HsIQ3.js +1 -0
  6. package/web/dist/assets/{ChannelConfigView-WJ-zUV8p.js → ChannelConfigView---Dwl3Fk.js} +3 -3
  7. package/web/dist/assets/ChartsView-Dw6G-jf3.js +1 -0
  8. package/web/dist/assets/{ConnectorsView-DaHmxnGE.js → ConnectorsView-BWvdrpyK.js} +2 -2
  9. package/web/dist/assets/{DiffPreview-D8tIj_aF.js → DiffPreview-WQihq3bK.js} +57 -56
  10. package/web/dist/assets/{FileContextMenu-C5WYeBNu.js → FileContextMenu-CyjXlSHp.js} +1 -1
  11. package/web/dist/assets/FileTreeView-Cafy33nT.js +1 -0
  12. package/web/dist/assets/HookConfigView-D-lASVju.js +2 -0
  13. package/web/dist/assets/InboxView-BWajw-Yx.js +1 -0
  14. package/web/dist/assets/InputArea-CSqaA55j.js +31 -0
  15. package/web/dist/assets/Install-ClEm4oGX.js +2 -0
  16. package/web/dist/assets/MemoryView-DLri75dm.js +1 -0
  17. package/web/dist/assets/ModelsView-BBLUMzR5.js +1 -0
  18. package/web/dist/assets/PluginsView-C-fnbDGZ.js +1 -0
  19. package/web/dist/assets/ProjectsView-BruI2W_l.js +1 -0
  20. package/web/dist/assets/{SessionGrid-BQSrCDqQ.js → SessionGrid-7GLpwn6d.js} +4 -4
  21. package/web/dist/assets/SettingsModal-cc9Qu2QU.js +4 -0
  22. package/web/dist/assets/SkillsView-Bf-2-U_q.js +1 -0
  23. package/web/dist/assets/TemplatesTab-CKul8nbL.js +2 -0
  24. package/web/dist/assets/{ToolsView-CjdYiaNz.js → ToolsView-D_aluOsK.js} +1 -1
  25. package/web/dist/assets/WorkspaceDirPicker-Z42YqE4a.js +5 -0
  26. package/web/dist/assets/{agentIconSet-CDeMxTHf.js → agentIconSet-Cqhm4UOl.js} +1 -1
  27. package/web/dist/assets/api-BW4-5gtM.js +1 -0
  28. package/web/dist/assets/chatStore-D8Zzr1hE.js +242 -0
  29. package/web/dist/assets/cn-CoHJgTJ5.js +1 -0
  30. package/web/dist/assets/{common-CPZxdYLs.js → common-CP2UB8TN.js} +99 -99
  31. package/web/dist/assets/icons-CittejKL.js +1 -0
  32. package/web/dist/assets/imageUrl-BVgcEm7e.js +2 -0
  33. package/web/dist/assets/index-CEUbTcNL.css +1 -0
  34. package/web/dist/assets/index-CxrzleFg.js +122 -0
  35. package/web/dist/assets/{markdown-Cps-36Z5.js → markdown-DZQBOzWk.js} +1 -1
  36. package/web/dist/assets/{panels-DCwx2Pbu.js → panels-CuDz4aqU.js} +1 -1
  37. package/web/dist/assets/projectsStore-B7fdKRzl.js +1 -0
  38. package/web/dist/assets/{react-vendor-CXI113IS.js → react-vendor-BEA-EtI-.js} +1 -1
  39. package/web/dist/assets/{settingsStore-BSdi9gNd.js → settingsStore-DYqiXodu.js} +1 -1
  40. package/web/dist/assets/src-55YckF5W.js +2 -0
  41. package/web/dist/assets/{state-pOTP5BEk.js → state-A4wJ8QgR.js} +1 -1
  42. package/web/dist/assets/{statusAxesRefresh--2evRuAU.js → statusAxesRefresh-BBqszCp-.js} +1 -1
  43. package/web/dist/assets/sttLanguages-jnSk4aqg.js +6 -0
  44. package/web/dist/assets/threadStore-CQi4OzSe.js +1 -0
  45. package/web/dist/assets/useConfirm-kTv3x0H6.js +1 -0
  46. package/web/dist/assets/{useTranslation-gGKZZfux.js → useTranslation-2BGEBvJE.js} +1 -1
  47. package/web/dist/assets/websocket-DCs7f54y.js +1 -0
  48. package/web/dist/assets/whatsNewStore-DoCQvcMq.js +1 -0
  49. package/web/dist/index.html +27 -23
  50. package/web/dist/assets/AutomationView-DfAF2L92.js +0 -3
  51. package/web/dist/assets/Button-D-g7PgYh.js +0 -1
  52. package/web/dist/assets/ChartsView-CSAfGqTC.js +0 -1
  53. package/web/dist/assets/FileTreeView-B7IN0KmE.js +0 -1
  54. package/web/dist/assets/HookConfigView-9gqvrRhQ.js +0 -2
  55. package/web/dist/assets/InboxView-BcEfijbj.js +0 -1
  56. package/web/dist/assets/InputArea-D5F91Uwk.js +0 -14
  57. package/web/dist/assets/Install-Cuelo0If.js +0 -2
  58. package/web/dist/assets/MemoryView-BvZSh5-T.js +0 -1
  59. package/web/dist/assets/ModelsView-BgvMN8xv.js +0 -1
  60. package/web/dist/assets/PluginsView-C3d6e8vV.js +0 -1
  61. package/web/dist/assets/ProjectsView-CM7GOsoK.js +0 -1
  62. package/web/dist/assets/SettingsModal-BvGXq5EE.js +0 -4
  63. package/web/dist/assets/SkillsView-87kGRliE.js +0 -1
  64. package/web/dist/assets/TemplatesTab-8MLwVNwV.js +0 -1
  65. package/web/dist/assets/api-ZQf0Ys8y.js +0 -1
  66. package/web/dist/assets/icons-B8Ngx6rM.js +0 -1
  67. package/web/dist/assets/imageUrl-CrQM4gmf.js +0 -74
  68. package/web/dist/assets/index-Bm7r92T3.css +0 -1
  69. package/web/dist/assets/index-STsyoFCk.js +0 -145
  70. package/web/dist/assets/src-BK8SoTFV.js +0 -1
  71. package/web/dist/assets/sttLanguages-BPcOF0nQ.js +0 -2
  72. package/web/dist/assets/useConfirm-CQjBnYuP.js +0 -1
  73. package/web/dist/assets/websocket-CeKJTCdp.js +0 -1
  74. package/web/dist/assets/whatsNewStore-C0hbStfc.js +0 -1
  75. package/web/dist/assets/workspaceSemantics-CW8ytHq2.js +0 -3
@@ -1 +1 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$t as t,A as n,Ar as r,Br as i,Dr as a,Dt as o,E as s,Er as c,G as l,Gn as u,Ht as d,Ir as f,It as p,Jn as m,Mr as ee,On as te,Ot as h,R as ne,Rt as re,Tn as ie,Un as ae,Ur as oe,W as se,Yn as g,Z as ce,_ as le,_r as ue,at as de,bn as fe,cn as pe,ct as _,d as v,ei as me,en as he,ft as ge,ir as _e,ln as ve,ni as ye,nn as be,nr as y,or as b,r as x,s as S,sn as C,sr as w,u as T,w as E,wn as D,zr as O}from"./icons-B8Ngx6rM.js";import{r as k}from"./react-vendor-CXI113IS.js";import{t as A}from"./useTranslation-gGKZZfux.js";import{i as j,n as M}from"./Button-D-g7PgYh.js";import{t as N}from"./api-ZQf0Ys8y.js";import{I as xe}from"./markdown-Cps-36Z5.js";var P=e(ye(),1),Se=k(),F=xe();function I(e){window.dispatchEvent(new CustomEvent(`preview-file`,{detail:{path:e}}))}var Ce=24,we=1.7;function L(e,t,n=1.15){return(0,F.jsx)(`circle`,{cx:e,cy:t,r:n,fill:`currentColor`,stroke:`none`})}function R(e,t,n=we){let r=(0,P.forwardRef)(function({size:e=Ce,strokeWidth:r=n,className:i,...a},o){let{absoluteStrokeWidth:s,nonScalingStroke:c,...l}=a;return(0,F.jsx)(`svg`,{ref:o,xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:r,strokeLinecap:`round`,strokeLinejoin:`round`,className:i,"aria-hidden":`true`,...l,children:t})});return r.displayName=`DomainGlyph(${e})`,r}var z={turn:R(`turn`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.4`}),L(12,3.6,1.9),(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.4`})]})),context:R(`context`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M8.2 4H5.6v16h2.6`}),(0,F.jsx)(`path`,{d:`M15.8 4h2.6v16h-2.6`}),L(12,8.4),L(12,12),L(12,15.6)]})),compact:R(`compact`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M12 3.4v6.2`}),(0,F.jsx)(`path`,{d:`M8.8 6.8 12 10 15.2 6.8`}),(0,F.jsx)(`path`,{d:`M12 20.6v-6.2`}),(0,F.jsx)(`path`,{d:`M8.8 17.2 12 14 15.2 17.2`}),(0,F.jsx)(`path`,{d:`M4.6 12h14.8`})]})),token:R(`token`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M12 3.4 20.6 12 12 20.6 3.4 12z`}),(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.6`})]})),subagent:R(`subagent`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`9.2`,cy:`15`,r:`5`}),(0,F.jsx)(`circle`,{cx:`18.3`,cy:`6.6`,r:`2.4`}),(0,F.jsx)(`path`,{d:`M12.9 11.6 16.5 8.2`})]})),workflow:R(`workflow`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`5.4`,cy:`12`,r:`2.2`}),(0,F.jsx)(`circle`,{cx:`18.6`,cy:`6.4`,r:`2.2`}),(0,F.jsx)(`circle`,{cx:`18.6`,cy:`17.6`,r:`2.2`}),(0,F.jsx)(`path`,{d:`M7.6 12h6.4`}),(0,F.jsx)(`path`,{d:`M14 12V6.4h2.4`}),(0,F.jsx)(`path`,{d:`M14 12v5.6h2.4`})]})),gate:R(`gate`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M6.6 4.4v15.2`}),(0,F.jsx)(`path`,{d:`M17.4 4.4v15.2`}),(0,F.jsx)(`path`,{d:`M6.6 9.6h10.8`}),(0,F.jsx)(`path`,{d:`M6.6 14.4h10.8`})]})),router:R(`router`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M3.4 12h5.4`}),(0,F.jsx)(`path`,{d:`M8.8 12 12.4 6.2 17.6 6.2`}),(0,F.jsx)(`path`,{d:`M8.8 12h8.8`}),(0,F.jsx)(`path`,{d:`M8.8 12 12.4 17.8 17.6 17.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`6.2`,r:`1.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`12`,r:`1.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`17.8`,r:`1.8`})]}))},Te=Object.keys(z),B={rating:s,difficulty:fe,distance:d,location:d,price:ue,time:w,duration:w,people:v,servings:v,tag:E,date:ee,level:be,heat:te,diet:t,food:T,drink:_e,stock:o,category:se},V={app:me,appFallback:oe,cart:ne,code:b,bookmark:i,prev:a,next:c,image:ve,sparkle:n,info:C,dot:g},H={chat:p,projects:ie,charts:r,assistants:O,templates:he,models:f,tools:x,skills:n,channels:de,connectors:ge,plugins:_,hooks:S,insights:le,inbox:pe,scheduled:w,memory:h,logs:ce,settings:l,pluginFallback:_},Ee={Activity:`insights`,BarChart3:`charts`,Bot:`assistants`,Brain:`models`,Clock:`scheduled`,Database:`memory`,FolderKanban:`projects`,Layers:`templates`,MessageSquare:`chat`,Plug:`connectors`,Puzzle:`plugins`,Radio:`channels`,ScrollText:`logs`,Settings:`settings`,Sparkles:`skills`,Webhook:`hooks`,Wrench:`tools`};function De(e){if(!e)return H.pluginFallback;if(e in H)return H[e];let t=Ee[e];return t?H[t]:H.pluginFallback}function Oe(e){return e?B[e]??ke(e)??g:g}function ke(e){return e in z?z[e]:void 0}[...Object.entries(B).map(([e,t])=>({name:e,icon:t})),...Object.entries(V).map(([e,t])=>({name:`ui.${e}`,icon:t})),...Object.entries(H).map(([e,t])=>({name:`nav.${e}`,icon:t})),...Te.map(e=>({name:`glyph.${e}`,icon:z[e]}))];var U=null;function Ae(e){U=e}var W=null;function je(e){W=e}function Me(e){W===e&&(W=null)}function Ne(e){return W?(W(e),!0):!1}function Pe(e){U===e&&(U=null)}function Fe(e){return U?(U(e),!0):!1}function Ie(e,t={}){let n=t.width??200,r=t.height??170;return{x:Math.max(4,Math.min(e.clientX,window.innerWidth-n)),y:Math.max(4,Math.min(e.clientY,window.innerHeight-r))}}var Le=28,Re=9,ze=8;function G(e,t=0){return e*Le+t*Re+ze}var K=1;function q(e){return e?e.getBoundingClientRect():null}function J(e,t,n){if(!t||!t.isConnected)return!1;let r=e.target;if(r instanceof Node&&!r.contains(t))return!0;if(n){let e=t.getBoundingClientRect();if(Math.abs(e.top-n.top)<K&&Math.abs(e.left-n.left)<K)return!0}return!1}var Y=(0,P.memo)(function({items:e,position:t,onClose:n,anchor:r,ariaLabel:i,minWidth:a=168}){let o=t!==null,{visible:s,phase:c}=M(o),l=(0,P.useRef)(t);t&&(l.current=t);let u=t??l.current,d=(0,P.useRef)(null);return(0,P.useLayoutEffect)(()=>{d.current=o?q(r):null},[o,r]),(0,P.useEffect)(()=>{if(!o)return;let e=()=>n(),t=e=>{e.key===`Escape`&&n()},i=e=>{J(e,r,d.current)||n()};return window.addEventListener(`click`,e),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,i,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`keydown`,t)}},[o,n,r]),!s||!u?null:(0,Se.createPortal)((0,F.jsx)(`div`,{role:`menu`,"aria-label":i,"data-phase":c,className:`fixed z-[9999] rounded-lg border border-dark-border bg-dark-overlay ui-surface-overlay py-1 shadow-[0_10px_32px_rgba(0,0,0,0.28)] ui-overlay-panel-fade`,style:{left:u.x,top:u.y,minWidth:a},onClick:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:e.map(e=>{if(e.kind===`separator`)return(0,F.jsx)(`div`,{role:`separator`,className:`my-1 h-px bg-dark-border/60`},e.id);let t=e.icon;return(0,F.jsxs)(`button`,{role:`menuitem`,disabled:e.disabled,onClick:()=>{n(),e.onSelect()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-start text-xs transition-colors ${e.disabled?`cursor-not-allowed text-dark-muted/35`:`text-dark-muted hover:bg-dark-hover hover:text-dark-text`}`,children:[t?(0,F.jsx)(t,{size:13,"aria-hidden":`true`,className:`shrink-0 opacity-70`}):null,(0,F.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)})}),document.body)});function Be(e){return typeof Element<`u`&&e instanceof Element?e:null}function X(){let[e,t]=(0,P.useState)(null),n=(0,P.useCallback)((e,n,r,i,a)=>{t({...Ie({clientX:e,clientY:n},i),data:r,anchor:a??null})},[]);return{state:e,open:(0,P.useCallback)((e,t,r,i)=>{e.preventDefault(),e.stopPropagation(),n(e.clientX,e.clientY,t,r,i??Be(e.target))},[n]),openAt:n,close:(0,P.useCallback)(()=>t(null),[])}}function Z(e){return e.success?{ok:!0}:{ok:!1,error:e.error||`unknown error`}}var Q={open:e=>N.fs.open(e,`open`).then(Z),reveal:e=>N.fs.open(e,`reveal`).then(Z),openFolder:e=>N.fs.openFolder(e).then(Z),download:e=>N.files.download(e).then(Z)},$=208,Ve=G(6,1);function He(){let{t:e}=A(),{state:t,open:n,close:r}=X(),i=t?.data??null,a=(0,P.useCallback)((e,t)=>n(e,t,{width:$,height:Ve}),[n]),o=(0,P.useCallback)((e,t)=>{e.then(e=>{e.ok||j.error(e.error||t)})},[]),s=(0,P.useMemo)(()=>i?[{id:`preview`,label:e(`fileMenu.preview`),icon:ae,onSelect:()=>I(i)},{id:`openExternal`,label:e(`fileMenu.openExternal`),icon:u,onSelect:()=>o(Q.open(i),e(`fileMenu.openFailed`))},{id:`reveal`,label:e(`fileMenu.reveal`),icon:D,onSelect:()=>o(Q.reveal(i),e(`fileMenu.revealFailed`))},{kind:`separator`,id:`sep-after-open`},{id:`addToChat`,label:e(`fileMenu.addToChat`),icon:re,onSelect:()=>{Fe(i)||j.warning(e(`fileMenu.noComposer`))}},{id:`copyPath`,label:e(`fileMenu.copyPath`),icon:y,onSelect:()=>{navigator.clipboard?.writeText(i).then(()=>j.success(e(`fileMenu.copied`)),()=>{})}},{id:`download`,label:e(`fileMenu.download`),icon:m,onSelect:()=>o(Q.download(i),e(`fileMenu.downloadFailed`))}]:[],[i,e,o]);return{openFileMenu:a,menuNode:(0,F.jsx)(Y,{items:s,position:t?{x:t.x,y:t.y}:null,anchor:t?.anchor??null,onClose:r,ariaLabel:e(`fileMenu.aria`),minWidth:$})}}export{q as a,Ne as c,Pe as d,Me as f,I as g,De as h,Y as i,Ae as l,Oe as m,Q as n,J as o,V as p,X as r,G as s,He as t,je as u};
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,An as n,Dn as r,Dt as i,E as a,En as o,G as s,Gn as c,Gr as l,Hr as u,Lt as d,Mr as ee,Or as f,Ot as p,Pr as te,R as ne,Rr as m,Sn as re,Ut as h,Vr as ie,W as ae,Xn as oe,Z as se,Zn as g,_ as ce,at as le,cr as ue,ct as _,d as v,dn as de,ft as fe,ii as pe,in as me,ir as he,kr as ge,ln as _e,lr as y,ni as ve,nn as ye,or as be,qn as b,r as x,s as S,tn as C,u as w,un as T,w as E,yr as D,zt as O}from"./icons-CittejKL.js";import{r as k}from"./react-vendor-BEA-EtI-.js";import{t as A}from"./useTranslation-2BGEBvJE.js";import{n as j,r as M}from"./Button-B43HsIQ3.js";import{t as N}from"./api-BW4-5gtM.js";import{I as xe}from"./markdown-DZQBOzWk.js";var P=e(pe(),1),Se=k(),F=xe();function I(e){window.dispatchEvent(new CustomEvent(`preview-file`,{detail:{path:e}}))}var Ce=24,we=1.7;function L(e,t,n=1.15){return(0,F.jsx)(`circle`,{cx:e,cy:t,r:n,fill:`currentColor`,stroke:`none`})}function R(e,t,n=we){let r=(0,P.forwardRef)(function({size:e=Ce,strokeWidth:r=n,className:i,...a},o){let{absoluteStrokeWidth:s,nonScalingStroke:c,...l}=a;return(0,F.jsx)(`svg`,{ref:o,xmlns:`http://www.w3.org/2000/svg`,width:e,height:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:r,strokeLinecap:`round`,strokeLinejoin:`round`,className:i,"aria-hidden":`true`,...l,children:t})});return r.displayName=`DomainGlyph(${e})`,r}var z={turn:R(`turn`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`8.4`}),L(12,3.6,1.9),(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.4`})]})),context:R(`context`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M8.2 4H5.6v16h2.6`}),(0,F.jsx)(`path`,{d:`M15.8 4h2.6v16h-2.6`}),L(12,8.4),L(12,12),L(12,15.6)]})),compact:R(`compact`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M12 3.4v6.2`}),(0,F.jsx)(`path`,{d:`M8.8 6.8 12 10 15.2 6.8`}),(0,F.jsx)(`path`,{d:`M12 20.6v-6.2`}),(0,F.jsx)(`path`,{d:`M8.8 17.2 12 14 15.2 17.2`}),(0,F.jsx)(`path`,{d:`M4.6 12h14.8`})]})),token:R(`token`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M12 3.4 20.6 12 12 20.6 3.4 12z`}),(0,F.jsx)(`circle`,{cx:`12`,cy:`12`,r:`2.6`})]})),subagent:R(`subagent`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`9.2`,cy:`15`,r:`5`}),(0,F.jsx)(`circle`,{cx:`18.3`,cy:`6.6`,r:`2.4`}),(0,F.jsx)(`path`,{d:`M12.9 11.6 16.5 8.2`})]})),workflow:R(`workflow`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`circle`,{cx:`5.4`,cy:`12`,r:`2.2`}),(0,F.jsx)(`circle`,{cx:`18.6`,cy:`6.4`,r:`2.2`}),(0,F.jsx)(`circle`,{cx:`18.6`,cy:`17.6`,r:`2.2`}),(0,F.jsx)(`path`,{d:`M7.6 12h6.4`}),(0,F.jsx)(`path`,{d:`M14 12V6.4h2.4`}),(0,F.jsx)(`path`,{d:`M14 12v5.6h2.4`})]})),gate:R(`gate`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M6.6 4.4v15.2`}),(0,F.jsx)(`path`,{d:`M17.4 4.4v15.2`}),(0,F.jsx)(`path`,{d:`M6.6 9.6h10.8`}),(0,F.jsx)(`path`,{d:`M6.6 14.4h10.8`})]})),router:R(`router`,(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`path`,{d:`M3.4 12h5.4`}),(0,F.jsx)(`path`,{d:`M8.8 12 12.4 6.2 17.6 6.2`}),(0,F.jsx)(`path`,{d:`M8.8 12h8.8`}),(0,F.jsx)(`path`,{d:`M8.8 12 12.4 17.8 17.6 17.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`6.2`,r:`1.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`12`,r:`1.8`}),(0,F.jsx)(`circle`,{cx:`19.4`,cy:`17.8`,r:`1.8`})]}))},Te=Object.keys(z),B={rating:a,difficulty:re,distance:h,location:h,price:D,time:y,duration:y,people:v,servings:v,tag:E,date:te,level:me,heat:n,diet:C,food:w,drink:be,stock:i,category:ae},V={app:ve,appFallback:l,cart:ne,code:ue,bookmark:u,prev:ge,next:f,image:de,sparkle:t,info:_e,dot:g},H={chat:d,projects:r,charts:ee,assistants:ie,templates:ye,models:m,tools:x,skills:t,channels:le,connectors:fe,plugins:_,hooks:S,insights:ce,inbox:T,scheduled:y,memory:p,logs:se,settings:s,pluginFallback:_},Ee={Activity:`insights`,BarChart3:`charts`,Bot:`assistants`,Brain:`models`,Clock:`scheduled`,Database:`memory`,FolderKanban:`projects`,Layers:`templates`,MessageSquare:`chat`,Plug:`connectors`,Puzzle:`plugins`,Radio:`channels`,ScrollText:`logs`,Settings:`settings`,Sparkles:`skills`,Webhook:`hooks`,Wrench:`tools`};function De(e){if(!e)return H.pluginFallback;if(e in H)return H[e];let t=Ee[e];return t?H[t]:H.pluginFallback}function Oe(e){return e?B[e]??ke(e)??g:g}function ke(e){return e in z?z[e]:void 0}[...Object.entries(B).map(([e,t])=>({name:e,icon:t})),...Object.entries(V).map(([e,t])=>({name:`ui.${e}`,icon:t})),...Object.entries(H).map(([e,t])=>({name:`nav.${e}`,icon:t})),...Te.map(e=>({name:`glyph.${e}`,icon:z[e]}))];var U=null;function Ae(e){U=e}var W=null;function je(e){W=e}function Me(e){W===e&&(W=null)}function Ne(e){return W?(W(e),!0):!1}function Pe(e){U===e&&(U=null)}function Fe(e){return U?(U(e),!0):!1}function Ie(e,t={}){let n=t.width??200,r=t.height??170;return{x:Math.max(4,Math.min(e.clientX,window.innerWidth-n)),y:Math.max(4,Math.min(e.clientY,window.innerHeight-r))}}var Le=28,Re=9,ze=8;function G(e,t=0){return e*Le+t*Re+ze}var K=1;function q(e){return e?e.getBoundingClientRect():null}function J(e,t,n){if(!t||!t.isConnected)return!1;let r=e.target;if(r instanceof Node&&!r.contains(t))return!0;if(n){let e=t.getBoundingClientRect();if(Math.abs(e.top-n.top)<K&&Math.abs(e.left-n.left)<K)return!0}return!1}var Y=(0,P.memo)(function({items:e,position:t,onClose:n,anchor:r,ariaLabel:i,minWidth:a=168}){let o=t!==null,{visible:s,phase:c}=j(o),l=(0,P.useRef)(t);t&&(l.current=t);let u=t??l.current,d=(0,P.useRef)(null);return(0,P.useLayoutEffect)(()=>{d.current=o?q(r):null},[o,r]),(0,P.useEffect)(()=>{if(!o)return;let e=()=>n(),t=e=>{e.key===`Escape`&&n()},i=e=>{J(e,r,d.current)||n()};return window.addEventListener(`click`,e),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,i,!0),window.addEventListener(`keydown`,t),()=>{window.removeEventListener(`click`,e),window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`keydown`,t)}},[o,n,r]),!s||!u?null:(0,Se.createPortal)((0,F.jsx)(`div`,{role:`menu`,"aria-label":i,"data-phase":c,className:`fixed z-[9999] rounded-lg border border-dark-border bg-dark-overlay ui-surface-overlay py-1 shadow-[0_10px_32px_rgba(0,0,0,0.28)] ui-overlay-panel-fade`,style:{left:u.x,top:u.y,minWidth:a},onClick:e=>e.stopPropagation(),onContextMenu:e=>e.preventDefault(),children:e.map(e=>{if(e.kind===`separator`)return(0,F.jsx)(`div`,{role:`separator`,className:`my-1 h-px bg-dark-border/60`},e.id);let t=e.icon;return(0,F.jsxs)(`button`,{role:`menuitem`,disabled:e.disabled,onClick:()=>{n(),e.onSelect()},className:`flex w-full items-center gap-2 rounded-md px-2.5 py-1.5 text-start text-xs transition-colors ${e.disabled?`cursor-not-allowed text-dark-muted/35`:`text-dark-muted hover:bg-dark-hover hover:text-dark-text`}`,children:[t?(0,F.jsx)(t,{size:13,"aria-hidden":`true`,className:`shrink-0 opacity-70`}):null,(0,F.jsx)(`span`,{className:`truncate`,children:e.label})]},e.id)})}),document.body)});function Be(e){return typeof Element<`u`&&e instanceof Element?e:null}function X(){let[e,t]=(0,P.useState)(null),n=(0,P.useCallback)((e,n,r,i,a)=>{t({...Ie({clientX:e,clientY:n},i),data:r,anchor:a??null})},[]);return{state:e,open:(0,P.useCallback)((e,t,r,i)=>{e.preventDefault(),e.stopPropagation(),n(e.clientX,e.clientY,t,r,i??Be(e.target))},[n]),openAt:n,close:(0,P.useCallback)(()=>t(null),[])}}function Z(e){return e.success?{ok:!0}:{ok:!1,error:e.error||`unknown error`}}var Q={open:e=>N.fs.open(e,`open`).then(Z),reveal:e=>N.fs.open(e,`reveal`).then(Z),openFolder:e=>N.fs.openFolder(e).then(Z),download:e=>N.files.download(e).then(Z)},$=208,Ve=G(6,1);function He(){let{t:e}=A(),{state:t,open:n,close:r}=X(),i=t?.data??null,a=(0,P.useCallback)((e,t)=>n(e,t,{width:$,height:Ve}),[n]),s=(0,P.useCallback)((e,t)=>{e.then(e=>{e.ok||M.error(e.error||t)})},[]),l=(0,P.useMemo)(()=>i?[{id:`preview`,label:e(`fileMenu.preview`),icon:c,onSelect:()=>I(i)},{id:`openExternal`,label:e(`fileMenu.openExternal`),icon:b,onSelect:()=>s(Q.open(i),e(`fileMenu.openFailed`))},{id:`reveal`,label:e(`fileMenu.reveal`),icon:o,onSelect:()=>s(Q.reveal(i),e(`fileMenu.revealFailed`))},{kind:`separator`,id:`sep-after-open`},{id:`addToChat`,label:e(`fileMenu.addToChat`),icon:O,onSelect:()=>{Fe(i)||M.warning(e(`fileMenu.noComposer`))}},{id:`copyPath`,label:e(`fileMenu.copyPath`),icon:he,onSelect:()=>{navigator.clipboard?.writeText(i).then(()=>M.success(e(`fileMenu.copied`)),()=>{})}},{id:`download`,label:e(`fileMenu.download`),icon:oe,onSelect:()=>s(Q.download(i),e(`fileMenu.downloadFailed`))}]:[],[i,e,s]);return{openFileMenu:a,menuNode:(0,F.jsx)(Y,{items:l,position:t?{x:t.x,y:t.y}:null,anchor:t?.anchor??null,onClose:r,ariaLabel:e(`fileMenu.aria`),minWidth:$})}}export{q as a,Ne as c,Pe as d,Me as f,I as g,De as h,Y as i,Ae as l,Oe as m,Q as n,J as o,V as p,X as r,G as s,He as t,je as u};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{$ as t,Ar as n,Cn as r,Or as i,Xn as a,Y as o,ii as s,it as c,jn as l,kr as u,m as d,pn as ee,xn as f}from"./icons-CittejKL.js";import{t as te}from"./react-vendor-BEA-EtI-.js";import{t as ne}from"./useTranslation-2BGEBvJE.js";import{r as p}from"./Button-B43HsIQ3.js";import{t as m}from"./api-BW4-5gtM.js";import{I as h}from"./markdown-DZQBOzWk.js";import{t as g}from"./cn-CoHJgTJ5.js";import{t as re}from"./useConfirm-kTv3x0H6.js";import{st as _}from"./index-CxrzleFg.js";var v=e(s(),1),y=h();function ie(e){return{ts:`typescript`,tsx:`typescript`,js:`javascript`,jsx:`javascript`,py:`python`,rs:`rust`,go:`go`,rb:`ruby`,json:`json`,xml:`xml`,html:`html`,css:`css`,scss:`scss`,md:`markdown`,yaml:`yaml`,yml:`yaml`,toml:`toml`,sql:`sql`,sh:`shell`,bat:`bat`,ps1:`powershell`,dockerfile:`dockerfile`,properties:`properties`,c:`c`,cpp:`cpp`,h:`c`,hpp:`cpp`,cs:`csharp`,vue:`html`,svelte:`html`,svg:`xml`}[e.split(`.`).pop()?.toLowerCase()||``]||`plaintext`}function b(){let{t:e}=ne(),[s,h]=re(),[b,x]=(0,v.useState)([]),[S,C]=(0,v.useState)(null),[w,T]=(0,v.useState)(``),[E,D]=(0,v.useState)(``),[ae,O]=(0,v.useState)(!1),[k,A]=(0,v.useState)(``),[j,M]=(0,v.useState)(!1),[N,P]=(0,v.useState)(!1),[F,I]=(0,v.useState)(!1),[L,oe]=(0,v.useState)(``),R=(0,v.useRef)(null),z=_(e=>e.status?.branch),se=_(e=>e.status?.available),[B,V]=(0,v.useState)(0),H=(0,v.useRef)(void 0);(0,v.useEffect)(()=>{S?(O(!0),m.files.read(S).then(t=>{if(t.success&&t.data){let e=typeof t.data==`string`?t.data:JSON.stringify(t.data);T(e),D(e)}else p.error(t.error||e(`fileTree.readFail`))}).catch(()=>p.error(e(`fileTree.readFail`))).finally(()=>O(!1))):(T(``),D(``))},[S,B]);let U=async e=>{M(!0);try{let t=await m.files.list(e);t.success&&Array.isArray(t.data)&&x(t.data.map(e=>({...e,expanded:!1})))}finally{M(!1)}};(0,v.useEffect)(()=>{H.current===void 0?H.current=z:z!==H.current&&(H.current=z,V(e=>e+1),U())},[z]);let W=async e=>{if(e.type===`directory`)try{let t=await m.files.list(e.path);if(t.success&&Array.isArray(t.data)){let n=t.data.map(e=>({...e,expanded:!1}));x(t=>G(t,e.id,n))}}catch{}},G=(e,t,n)=>e.map(e=>e.id===t?{...e,children:n,expanded:!0}:e.children?{...e,children:G(e.children,t,n)}:e);(0,v.useEffect)(()=>{U()},[]);let ce=e=>{let t=q(b,e);t&&t.type===`directory`&&!t.children?W(t):x(t=>K(t,e))},K=(e,t)=>e.map(e=>e.id===t&&e.type===`directory`?{...e,expanded:!e.expanded}:e.children?{...e,children:K(e.children,t)}:e),q=(e,t)=>{for(let n of e){if(n.id===t)return n;if(n.children){let e=q(n.children,t);if(e)return e}}return null},J=(e,t)=>t?e.reduce((e,n)=>{if(n.name.toLowerCase().includes(t.toLowerCase()))e.push(n);else if(n.children){let r=J(n.children,t);r.length>0&&e.push({...n,children:r,expanded:!0})}return e},[]):e,le=(0,v.useCallback)(async()=>{if(S){P(!0);try{let t=await m.files.update(S,w);t.success?(D(w),p.success(e(`fileTree.saved`))):p.error(t.error||e(`fileTree.saveFail`))}catch{p.error(e(`fileTree.saveFail`))}finally{P(!1)}}},[S,w,e]),Y=()=>{C(null),T(``),D(``)},X=(0,v.useCallback)(async t=>{let n=await m.files.download(t);n.success?p.success(e(`fileTree.downloadStarted`)):p.error(n.error||e(`fileTree.downloadFail`))},[e]),ue=()=>R.current?.click(),de=(0,v.useCallback)(async t=>{if(!t||t.length===0)return;let n=L||(S?S.replace(/[\\/][^\\/]+$/,``):``);I(!0);let r=0,i=0;for(let e of Array.from(t)){let t=n?`${n}/${e.name}`:e.name;(await m.files.upload(e,t)).success?r++:i++}I(!1),r>0&&p.success(e(`fileTree.uploadedCount`,{count:r})),i>0&&p.error(e(`fileTree.uploadFailedCount`,{count:i})),await U()},[L,S,e]),Z=w!==E,Q=async()=>!Z||h({message:e(`fileTree.discardConfirm`,{file:S||``}),variant:`danger`}),fe=async()=>{await Q()&&Y()},$=(t,o=0)=>{let s=t.type===`directory`,c=S===t.path,l=L===t.path;return(0,y.jsxs)(`div`,{children:[(0,y.jsxs)(`div`,{className:`group flex items-center gap-1 px-2 py-0.5 cursor-pointer rounded text-xs transition-colors max-md:w-max max-md:min-w-full ${c?`bg-accent-blue/20 text-accent-blue`:l?`bg-accent-blue/10`:`hover:bg-dark-hover`}`,style:{paddingLeft:`${o*14+6}px`},onClick:()=>s?(oe(t.path),ce(t.id)):C(t.path),title:s?e(`fileTree.setUploadDirHint`):t.path,children:[s&&(0,y.jsx)(`span`,{className:`text-dark-muted shrink-0`,children:t.expanded?(0,y.jsx)(n,{size:12}):(0,y.jsx)(i,{size:12})}),s?(0,y.jsx)(r,{size:12,className:`text-accent-yellow shrink-0`}):(0,y.jsx)(`span`,{className:`w-3`}),(0,y.jsx)(`span`,{className:`truncate flex-1`,children:t.name}),!s&&(0,y.jsx)(`button`,{onClick:e=>{e.stopPropagation(),X(t.path)},className:`opacity-0 group-hover:opacity-100 p-0.5 rounded hover:bg-dark-border text-dark-muted hover:text-dark-text shrink-0 max-md:opacity-100`,title:e(`fileTree.download`),children:(0,y.jsx)(a,{size:11})})]}),s&&t.expanded&&t.children?.map(e=>$(e,o+1))]},t.id)},pe=k?J(b,k):b;return(0,y.jsxs)(`div`,{className:`flex-1 flex overflow-hidden`,children:[s,(0,y.jsxs)(`div`,{className:g(`flex flex-col overflow-hidden flex-1 min-h-0`,S&&`hidden`),children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-2 border-b border-dark-border`,children:[se&&z&&(0,y.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1 text-meta text-dark-muted`,title:z,children:[(0,y.jsx)(f,{size:12,className:`shrink-0 text-accent-blue/80`,"aria-hidden":`true`}),(0,y.jsx)(`span`,{className:`truncate font-mono`,children:z})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-0.5 ms-auto`,children:[(0,y.jsx)(`button`,{onClick:ue,disabled:F,className:`p-1 rounded hover:bg-dark-hover disabled:opacity-50`,title:L?e(`fileTree.uploadTo`,{dir:L}):e(`fileTree.uploadToRoot`),children:(0,y.jsx)(d,{size:12,className:F?`animate-pulse`:``})}),(0,y.jsx)(`button`,{onClick:()=>U(),disabled:j,className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.refresh`),children:(0,y.jsx)(c,{size:12,className:j?`animate-spin`:``})}),(0,y.jsx)(`button`,{onClick:()=>{(async()=>{await Q()&&(x(b.map(e=>({...e,expanded:!1}))),Y())})()},className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.collapse`),children:(0,y.jsx)(ee,{size:12})})]})]}),(0,y.jsx)(`div`,{className:`p-1.5 border-b border-dark-border`,children:(0,y.jsxs)(`div`,{className:`relative`,children:[(0,y.jsx)(o,{size:12,className:`absolute start-2 top-1/2 -translate-y-1/2 text-dark-muted`}),(0,y.jsx)(`input`,{type:`text`,value:k,onChange:e=>A(e.target.value),placeholder:e(`fileTree.searchPlaceholder`),className:`w-full ps-6 pe-2 py-1 text-xs bg-dark-bg border border-dark-border rounded focus:border-accent-blue focus:outline-none`})]})}),(0,y.jsx)(`div`,{className:`flex-1 min-h-0 overflow-y-auto custom-scrollbar py-1 max-md:overflow-x-auto`,children:pe.map(e=>$(e))}),(0,y.jsx)(`input`,{ref:R,type:`file`,multiple:!0,className:`hidden`,onChange:e=>{de(e.target.files),e.currentTarget.value=``}})]}),(0,y.jsx)(`div`,{className:g(`flex-1 flex flex-col min-w-0 bg-dark-bg`,!S&&`hidden`),children:S?(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(`div`,{className:`flex items-center justify-between px-3 py-1.5 border-b border-dark-border bg-dark-surface max-md:gap-2`,children:[(0,y.jsxs)(`div`,{className:`flex items-center gap-2 text-xs min-w-0`,children:[(0,y.jsx)(`button`,{onClick:()=>void fe(),className:`p-0.5 -ms-1 rounded hover:bg-dark-hover text-dark-muted hover:text-dark-text shrink-0`,title:e(`fileTree.backToList`),"aria-label":e(`fileTree.backToList`),"data-testid":`file-tree-back`,children:(0,y.jsx)(u,{size:13})}),(0,y.jsx)(l,{size:12,className:`text-dark-muted shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:S}),Z&&(0,y.jsxs)(`span`,{className:`text-accent-yellow text-badge shrink-0`,children:[`● `,e(`fileTree.modified`)]})]}),(0,y.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,y.jsxs)(`button`,{onClick:le,disabled:!Z||N,className:`px-2 py-0.5 text-badge rounded flex items-center gap-1 transition-colors ${Z?`bg-accent-green text-accent-fg hover:opacity-90`:`bg-dark-border text-dark-muted cursor-not-allowed`}`,children:[(0,y.jsx)(t,{size:10}),e(N?`fileTree.saving`:`fileTree.save`)]}),(0,y.jsx)(`button`,{onClick:()=>void X(S),className:`p-1 rounded hover:bg-dark-hover`,title:e(`fileTree.download`),children:(0,y.jsx)(a,{size:12})})]})]}),(0,y.jsx)(`div`,{className:`flex-1 min-h-0`,children:ae?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`div`,{className:`w-4 h-4 border-2 border-accent-blue border-t-transparent rounded-full animate-spin`})}):(0,y.jsx)(te,{language:ie(S),value:w,onChange:e=>T(e||``),theme:`vs-dark`,options:{fontSize:13,fontFamily:`"Cascadia Code", "Fira Code", Consolas, monospace`,minimap:{enabled:!0,renderCharacters:!1,maxColumn:80,showSlider:`mouseover`},lineNumbers:`on`,scrollBeyondLastLine:!1,wordWrap:`on`,automaticLayout:!0,tabSize:2}})})]}):(0,y.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,y.jsxs)(`div`,{className:`text-center`,children:[(0,y.jsx)(l,{size:32,className:`text-dark-muted mx-auto mb-2`}),(0,y.jsx)(`p`,{className:`text-sm text-dark-muted`,children:e(`fileTree.selectFileHint`)})]})})})]})}export{b as FileTreeView};
@@ -0,0 +1,2 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,Ar as n,D as r,Or as i,V as a,Xn as o,Z as s,b as c,dt as l,en as u,ii as d,it as f,k as p,kr as m,m as h,n as g,pt as _,v,vt as y,y as b}from"./icons-CittejKL.js";import{t as x}from"./useTranslation-2BGEBvJE.js";import{n as S}from"./state-A4wJ8QgR.js";import{n as C,t as w}from"./Button-B43HsIQ3.js";import{t as T}from"./api-BW4-5gtM.js";import{I as E}from"./markdown-DZQBOzWk.js";import"./common-CP2UB8TN.js";import{r as D,t as O}from"./useConfirm-kTv3x0H6.js";var k=e(d(),1),A=S((e,t)=>({rules:[],templates:[],stats:null,events:[],agents:[],loading:!1,error:null,fieldErrors:null,formOpen:!1,editingRule:null,draftRule:null,dryRunResult:null,loadRules:async()=>{let t=await T.hooks.list();t.success&&Array.isArray(t.data)?e({rules:t.data}):t.success&&t.data&&!Array.isArray(t.data)?e({error:`服务端返回的规则数据格式异常`}):e({error:t.error||`Failed to load rules`})},loadTemplates:async()=>{let t=await T.hooks.templates();t.success&&Array.isArray(t.data)?e({templates:t.data}):t.success&&t.data&&!Array.isArray(t.data)&&e({error:`服务端返回的模板数据格式异常`})},loadStats:async()=>{let t=await T.hooks.stats();t.success&&t.data&&e({stats:t.data})},loadEvents:async()=>{let t=await T.hooks.events();t.success&&Array.isArray(t.data)?e({events:t.data}):t.success&&t.data&&!Array.isArray(t.data)&&e({error:`服务端返回的事件数据格式异常`})},loadAgents:async()=>{let t=await T.hooks.agents();t.success&&Array.isArray(t.data)?e({agents:t.data}):t.success&&t.data&&!Array.isArray(t.data)&&e({error:`服务端返回的Agent数据格式异常`})},loadAll:async()=>{e({loading:!0,error:null});try{await Promise.all([t().loadRules(),t().loadTemplates(),t().loadStats(),t().loadEvents(),t().loadAgents()])}catch(t){e({error:String(t)})}finally{e({loading:!1})}},createRule:async n=>{e({fieldErrors:null});let r=await T.hooks.create(n);if(r.success)return await t().loadRules(),await t().loadStats(),e({formOpen:!1,editingRule:null}),!0;if(r.error){e({error:r.error});try{let t=JSON.parse(r.error);t.fieldErrors&&e({fieldErrors:t.fieldErrors})}catch{}}return!1},updateRule:async(n,r)=>{e({fieldErrors:null});let i=await T.hooks.update(n,r);return i.success?(await t().loadRules(),await t().loadStats(),e({formOpen:!1,editingRule:null}),!0):(e({error:i.error||`Update failed`}),!1)},deleteRule:async n=>{let r=await T.hooks.delete(n);return r.success?(await t().loadRules(),await t().loadStats(),!0):(e({error:r.error||`Delete failed`}),!1)},batchDelete:async n=>{let r=await T.hooks.batchDelete(n);return r.success?(await t().loadRules(),await t().loadStats(),!0):(e({error:r.error||`Batch delete failed`}),!1)},toggleRule:async(n,r)=>(await T.hooks.toggle(n,r)).success?(e(e=>({rules:e.rules.map(e=>e.name===n?{...e,enabled:r}:e)})),await t().loadStats(),!0):(await t().loadRules(),!1),batchToggle:async(n,r)=>(await T.hooks.batchToggle(n,r)).success?(e(e=>({rules:e.rules.map(e=>n.includes(e.name)?{...e,enabled:r}:e)})),await t().loadStats(),!0):(await t().loadRules(),!1),dryRun:async t=>{let n=await T.hooks.dryRun(t);return n.success&&n.data?(e({dryRunResult:n.data}),n.data):(e({error:n.error||`Dry-run failed`}),null)},openForm:t=>e({formOpen:!0,editingRule:t||null,draftRule:null,dryRunResult:null,fieldErrors:null}),openFormFromTemplate:(t,n)=>e({formOpen:!0,editingRule:null,draftRule:{...t.rule,description:n||t.rule.description},dryRunResult:null,fieldErrors:null}),closeForm:()=>e({formOpen:!1,editingRule:null,draftRule:null,dryRunResult:null,fieldErrors:null}),setDryRunResult:t=>e({dryRunResult:t}),clearError:()=>e({error:null}),clearFieldErrors:()=>e({fieldErrors:null})})),j=E(),M={SYSTEM:`bg-accent-red/15 text-accent-red`,SECURITY:`bg-accent-orange/15 text-accent-orange`,PROJECT:`bg-accent-blue/15 text-accent-blue`,USER:`bg-accent-green/15 text-accent-green`,PLUGIN:`bg-accent-purple/15 text-accent-purple`},N={SHELL:`bg-accent-yellow/15 text-accent-yellow`,HTTP:`bg-accent-cyan/15 text-accent-cyan`,PROMPT:`bg-accent-purple/15 text-accent-purple`,AGENT:`bg-accent-blue/15 text-accent-blue`};function P({rules:e,onEdit:t}){let{t:n}=x(),[i,a]=O(),{toggleRule:o,deleteRule:s,batchDelete:c,batchToggle:l}=A(),[u,d]=(0,k.useState)(new Set),[f,m]=(0,k.useState)(!1),h=Array.isArray(e)?e:[];if(h.length===0)return(0,j.jsxs)(`div`,{className:`flex flex-1 flex-col items-center justify-center gap-3 py-16 text-dark-muted`,children:[(0,j.jsx)(`div`,{className:`text-4xl opacity-60`,children:`🪝`}),(0,j.jsx)(`p`,{className:`text-sm`,children:n(`hook.noRules`)}),(0,j.jsx)(`p`,{className:`text-xs text-dark-muted/70`,children:n(`hook.noRulesHint`)})]});let g=e=>{let t=new Set(u);t.has(e)?t.delete(e):t.add(e),d(t),m(t.size===h.length)},_=()=>{f?(d(new Set),m(!1)):(d(new Set(h.map(e=>e.name))),m(!0))},b=async()=>{u.size!==0&&await a({message:n(`hook.batchDeleteConfirm`,{n:u.size}),variant:`danger`})&&(c(Array.from(u)),d(new Set),m(!1))},S=e=>{u.size!==0&&(l(Array.from(u),e),d(new Set),m(!1))};return(0,j.jsxs)(`div`,{className:`flex flex-1 flex-col min-h-0`,children:[i,u.size>0&&(0,j.jsxs)(`div`,{className:`mb-2 flex items-center gap-2 rounded-lg border border-accent-blue/30 bg-accent-blue/5 px-3 py-1.5 text-sm`,children:[(0,j.jsx)(`span`,{className:`text-dark-muted`,children:n(`hook.selectedItems`,{n:u.size})}),(0,j.jsx)(`button`,{onClick:()=>S(!0),className:`rounded bg-accent-green/15 px-2 py-0.5 text-accent-green transition-colors hover:bg-accent-green/25`,children:n(`hook.enableAll`)}),(0,j.jsx)(`button`,{onClick:()=>S(!1),className:`rounded bg-dark-hover px-2 py-0.5 text-dark-text transition-colors hover:bg-dark-border`,children:n(`hook.disableAll`)}),(0,j.jsx)(`button`,{onClick:()=>void b(),className:`rounded bg-accent-red/15 px-2 py-0.5 text-accent-red transition-colors hover:bg-accent-red/25`,children:n(`common.delete`)})]}),(0,j.jsx)(`div`,{className:`flex-1 min-h-0 overflow-auto custom-scrollbar rounded-xl border border-dark-border`,children:(0,j.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,j.jsx)(`thead`,{className:`sticky top-0 bg-dark-hover text-dark-muted`,children:(0,j.jsxs)(`tr`,{children:[(0,j.jsx)(`th`,{className:`w-8 p-2.5`,children:(0,j.jsx)(`button`,{onClick:_,children:f?(0,j.jsx)(p,{size:14}):(0,j.jsx)(r,{size:14})})}),(0,j.jsx)(`th`,{className:`p-2.5 text-start font-medium`,children:n(`hook.colName`)}),(0,j.jsx)(`th`,{className:`p-2.5 text-start font-medium`,children:n(`hook.colEvents`)}),(0,j.jsx)(`th`,{className:`p-2.5 text-start font-medium`,children:n(`hook.colType`)}),(0,j.jsx)(`th`,{className:`p-2.5 text-start font-medium`,children:n(`hook.fieldPriority`)}),(0,j.jsx)(`th`,{className:`p-2.5 text-start font-medium`,children:n(`hook.colStatus`)}),(0,j.jsx)(`th`,{className:`p-2.5 text-end font-medium`,children:n(`hook.colActions`)})]})}),(0,j.jsx)(`tbody`,{className:`divide-y divide-dark-border`,children:h.map(e=>(0,j.jsxs)(`tr`,{className:`transition-colors hover:bg-dark-hover/50`,children:[(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsx)(`button`,{onClick:()=>g(e.name),children:u.has(e.name)?(0,j.jsx)(p,{size:14,className:`text-accent-blue`}):(0,j.jsx)(r,{size:14,className:`text-dark-muted`})})}),(0,j.jsxs)(`td`,{className:`p-2.5`,children:[(0,j.jsx)(`div`,{className:`font-medium text-dark-text`,children:e.name}),e.description&&(0,j.jsx)(`div`,{className:`mt-0.5 max-w-[220px] truncate text-xs text-dark-muted`,children:e.description})]}),(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsxs)(`div`,{className:`flex flex-wrap gap-1`,children:[Array.isArray(e.events)&&e.events.slice(0,3).map(e=>(0,j.jsx)(`span`,{className:`rounded bg-dark-hover px-1.5 py-0.5 text-xs text-dark-text`,children:e},e)),Array.isArray(e.events)&&e.events.length>3&&(0,j.jsxs)(`span`,{className:`px-1 py-0.5 text-xs text-dark-muted`,children:[`+`,e.events.length-3]})]})}),(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-xs font-medium ${N[e.implementationType]||`bg-dark-hover text-dark-muted`}`,children:e.implementationType})}),(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-xs font-medium ${M[e.priority]||`bg-dark-hover text-dark-muted`}`,children:e.priority})}),(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsx)(`button`,{onClick:()=>o(e.name,!e.enabled),className:`relative h-5 w-9 rounded-full transition-colors ${e.enabled?`bg-accent-green`:`bg-dark-border`}`,title:e.enabled?n(`hook.clickToDisable`):n(`hook.clickToEnable`),children:(0,j.jsx)(`span`,{className:`absolute top-0.5 block h-3.5 w-3.5 rounded-full bg-white transition-all ${e.enabled?`start-[18px]`:`start-[2px]`}`})})}),(0,j.jsx)(`td`,{className:`p-2.5`,children:(0,j.jsxs)(`div`,{className:`flex items-center justify-end gap-1`,children:[(0,j.jsx)(`button`,{onClick:()=>t(e),className:`rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-accent-blue`,title:n(`hook.actionEdit`),children:(0,j.jsx)(y,{size:14})}),(0,j.jsx)(`button`,{onClick:()=>{(async()=>{await a({message:n(`hook.deleteRuleConfirm`,{name:e.name}),variant:`danger`})&&s(e.name)})()},className:`rounded p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-accent-red`,title:n(`common.delete`),children:(0,j.jsx)(v,{size:14})})]})})]},e.name))})]})})]})}var F={name:``,description:``,events:[],implementationType:`SHELL`,command:``,url:``,promptTemplate:``,agentName:``,priority:`USER`,tools:[],matcherToolNamePattern:``,matcherFromState:``,matcherToState:``,timeoutMs:3e4,enabled:!0,failOpen:!0,onFailure:`fail-open`,scope:`project`},I=[{value:`SYSTEM`,label:`SYSTEM (100)`},{value:`SECURITY`,label:`SECURITY (80)`},{value:`PROJECT`,label:`PROJECT (60)`},{value:`USER`,label:`USER (40)`},{value:`PLUGIN`,label:`PLUGIN (20)`}],L=e=>`w-full rounded-lg border bg-dark-bg px-3 py-2 text-sm text-dark-text placeholder-dark-muted/60 transition-colors focus:outline-none focus:ring-2 ${e?`border-accent-red focus:border-accent-red focus:ring-accent-red/20`:`border-dark-border focus:border-accent-blue focus:ring-accent-blue/20`}`,R=`mb-1 block text-xs font-medium text-dark-muted`;function z({isOpen:e,events:t,agents:n}){let{t:r}=x(),{editingRule:a,draftRule:o,fieldErrors:s,dryRunResult:c,createRule:l,updateRule:u,closeForm:d,dryRun:f,setDryRunResult:p,clearFieldErrors:h}=A(),{visible:v,phase:y}=C(e),b=[{value:`SHELL`,label:r(`hook.implShell`),desc:r(`hook.implShellDesc`)},{value:`HTTP`,label:r(`hook.implHttp`),desc:r(`hook.implHttpDesc`)},{value:`PROMPT`,label:`LLM Prompt`,desc:r(`hook.implPromptDesc`)},{value:`AGENT`,label:`AI Agent`,desc:r(`hook.implAgentDesc`)}],S=Array.isArray(t)?t:[],T=Array.isArray(n)?n:[],[E,D]=(0,k.useState)(0),[O,M]=(0,k.useState)(F),[N,P]=(0,k.useState)(``),[z,B]=(0,k.useState)(``),[V,H]=(0,k.useState)(``),U=a??o;(0,k.useEffect)(()=>{if(!e)return;D(0),P(``),M(U?{name:U.name,description:U.description||``,events:U.events,implementationType:U.implementationType,command:U.command||``,url:U.url||``,promptTemplate:U.promptTemplate||``,agentName:U.agentName||``,priority:U.priority,tools:U.tools||[],matcherToolNamePattern:U.matchers?.toolNamePattern||``,matcherFromState:U.matchers?.fromState||``,matcherToState:U.matchers?.toState||``,timeoutMs:U.timeoutMs,enabled:U.enabled,failOpen:U.failOpen,onFailure:U.onFailure||(U.failOpen?`fail-open`:`block`),scope:U.scope||`project`}:F);let t=(U?.matchers?.toolNamePattern||``).trim().replace(/^\^|\$$/g,``);B(/^[A-Za-z0-9_]+$/.test(t)?t:``),H(``)},[e,U]);let W=(e,t)=>{M(n=>({...n,[e]:t})),h()},G=e=>{M(t=>({...t,events:t.events.includes(e)?t.events.filter(t=>t!==e):[...t.events,e]}))},K=e=>{e.every(e=>O.events.includes(e))?M(t=>({...t,events:t.events.filter(t=>!e.includes(t))})):M(t=>({...t,events:[...new Set([...t.events,...e])]}))},q=async()=>{let e={};O.matcherToolNamePattern&&(e.toolNamePattern=O.matcherToolNamePattern),O.matcherFromState&&(e.fromState=O.matcherFromState),O.matcherToState&&(e.toState=O.matcherToState);let t={...O,tools:O.tools.length>0?O.tools:[]};t.matchers=e,delete t.matcherToolNamePattern,delete t.matcherFromState,delete t.matcherToState,a?await u(a.name,t):await l(t)},J=async()=>{p(null);let e={};O.matcherToolNamePattern&&(e.toolNamePattern=O.matcherToolNamePattern),await f({hook:{name:O.name||`dry-run`,description:O.description,events:O.events,implementationType:O.implementationType,command:O.command,url:O.url,promptTemplate:O.promptTemplate,agentName:O.agentName,priority:O.priority,tools:O.tools,matchers:e,timeoutMs:O.timeoutMs,enabled:!0,failOpen:O.failOpen,onFailure:O.onFailure,scope:O.scope},eventType:O.events[0]||`PRE_TOOL_USE`,toolName:z.trim(),toolInput:V.trim()})},Y=N?S.map(e=>({...e,events:Array.isArray(e.events)?e.events.filter(e=>e.name.toLowerCase().includes(N.toLowerCase())||e.summary.includes(N)):[]})).filter(e=>e.events.length>0):S,X=[{title:r(`hook.stepBasicTitle`),desc:r(`hook.stepBasicDesc`)},{title:r(`hook.stepImplTitle`),desc:r(`hook.stepImplDesc`)},{title:r(`hook.stepAdvancedTitle`),desc:r(`hook.stepAdvancedDesc`)}];return v?(0,j.jsxs)(`div`,{className:`fixed inset-0 z-50 flex justify-end`,children:[(0,j.jsx)(`div`,{className:`absolute inset-0 ui-scrim ui-overlay-backdrop`,"data-phase":y,onClick:d}),(0,j.jsxs)(`div`,{className:`relative flex h-full w-[560px] flex-col border-s border-dark-border bg-dark-bg shadow-2xl ui-overlay-panel-edge max-md:w-full`,"data-phase":y,children:[(0,j.jsxs)(`div`,{className:`flex flex-shrink-0 items-center justify-between border-b border-dark-border px-4 py-3.5`,children:[(0,j.jsx)(`h3`,{className:`text-base font-semibold text-dark-text`,children:a?r(`hook.editRule`,{name:a.name}):r(`hook.addRule`)}),(0,j.jsx)(`button`,{onClick:d,className:`rounded-lg p-1 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,children:(0,j.jsx)(g,{size:18})})]}),(0,j.jsx)(`div`,{className:`flex flex-shrink-0 border-b border-dark-border`,children:X.map((e,t)=>{let n=t===E,r=t<E;return(0,j.jsxs)(`button`,{onClick:()=>D(t),className:`relative flex-1 border-b-2 px-2 py-2.5 text-center text-xs transition-colors ${n?`border-accent-blue bg-accent-blue/5 text-accent-blue`:r?`border-transparent text-dark-text`:`border-transparent text-dark-muted hover:text-dark-text`}`,children:[(0,j.jsx)(`span`,{className:`me-1 inline-flex h-4 w-4 items-center justify-center rounded-full text-badge ${n?`bg-accent-blue text-accent-fg`:r?`bg-accent-green text-accent-fg`:`bg-dark-hover text-dark-muted`}`,children:r?`✓`:t+1}),(0,j.jsx)(`span`,{className:`font-medium`,children:e.title})]},e.title)})}),(0,j.jsxs)(`div`,{className:`flex-1 min-h-0 space-y-4 overflow-auto custom-scrollbar p-4`,children:[s&&Object.keys(s).length>0&&(0,j.jsx)(`div`,{className:`rounded-lg border border-accent-red/40 bg-accent-red/10 p-2.5 text-xs text-accent-red`,children:Object.entries(s).map(([e,t])=>(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`strong`,{children:[e,`:`]}),` `,t]},e))}),E===0&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldName`)}),(0,j.jsx)(`input`,{value:O.name,onChange:e=>W(`name`,e.target.value),placeholder:`my-custom-hook`,className:L(s?.name)})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldDescription`)}),(0,j.jsx)(`textarea`,{value:O.description,onChange:e=>W(`description`,e.target.value),placeholder:r(`hook.descriptionPlaceholder`),rows:2,className:L()})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:`Scope`}),(0,j.jsxs)(`select`,{value:O.scope,onChange:e=>W(`scope`,e.target.value),className:L(),children:[(0,j.jsx)(`option`,{value:`project`,children:`project (.agent/hooks.json)`}),(0,j.jsx)(`option`,{value:`user`,children:`user (~/.agent/hooks.json)`}),(0,j.jsx)(`option`,{value:`local`,children:`local (.agent/hooks.local.json)`})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:`mb-1 flex items-center justify-between`,children:[(0,j.jsx)(`label`,{className:`text-xs font-medium text-dark-muted`,children:r(`hook.fieldEvents`)}),(0,j.jsx)(`span`,{className:`text-xs text-accent-blue`,children:r(`hook.eventsSelected`,{n:O.events.length})})]}),(0,j.jsx)(`input`,{value:N,onChange:e=>P(e.target.value),placeholder:r(`hook.searchEventsPlaceholder`),className:L()+` mb-2`}),(0,j.jsx)(`div`,{className:`max-h-[280px] space-y-2 overflow-auto custom-scrollbar rounded-lg border border-dark-border bg-dark-surface p-2`,children:Y.map(e=>(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`button`,{onClick:()=>K(e.events.map(e=>e.name)),className:`mb-1 text-xs font-medium text-dark-muted transition-colors hover:text-dark-text`,children:[e.category,` — `,r(`hook.toggleAllEvents`)]}),e.events.map(e=>{let t=O.events.includes(e.name);return(0,j.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2 rounded px-1 py-1 transition-colors hover:bg-dark-hover`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>G(e.name),className:`h-3.5 w-3.5 accent-accent-blue`}),(0,j.jsx)(`span`,{className:`text-xs text-dark-text`,children:e.name}),(0,j.jsxs)(`span`,{className:`truncate text-xs text-dark-muted`,children:[`— `,e.summary]})]},e.name)})]},e.category))})]})]}),E===1&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldImplType`)}),(0,j.jsx)(`div`,{className:`grid grid-cols-2 gap-2 max-md:grid-cols-1`,children:b.map(e=>{let t=O.implementationType===e.value;return(0,j.jsxs)(`button`,{onClick:()=>W(`implementationType`,e.value),className:`rounded-lg border p-3 text-start transition-colors ${t?`border-accent-blue bg-accent-blue/10 ring-1 ring-accent-blue/30`:`border-dark-border bg-dark-surface hover:bg-dark-hover`}`,children:[(0,j.jsx)(`div`,{className:`text-sm font-medium ${t?`text-accent-blue`:`text-dark-text`}`,children:e.label}),(0,j.jsx)(`div`,{className:`mt-1 text-xs text-dark-muted`,children:e.desc})]},e.value)})})]}),O.implementationType===`SHELL`&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldCommand`)}),(0,j.jsx)(`textarea`,{value:O.command,onChange:e=>W(`command`,e.target.value),placeholder:`python3 .agent/hooks/audit.py
2
+ 或 node -e "…"(WINDOWS 下命令内不要出现第二个双引号)`,rows:4,spellCheck:!1,className:`resize-y font-mono leading-relaxed ${L(s?.command)}`})]}),O.implementationType===`HTTP`&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:`URL *`}),(0,j.jsx)(`input`,{value:O.url,onChange:e=>W(`url`,e.target.value),placeholder:`https://example.com/hooks/audit`,className:L(s?.url)})]}),O.implementationType===`PROMPT`&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldPromptTemplate`)}),(0,j.jsx)(`textarea`,{value:O.promptTemplate,onChange:e=>W(`promptTemplate`,e.target.value),placeholder:r(`hook.promptTemplatePlaceholder`),rows:5,className:`font-mono ${L(s?.promptTemplate)}`})]}),O.implementationType===`AGENT`&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:`Agent *`}),(0,j.jsxs)(`select`,{value:O.agentName,onChange:e=>W(`agentName`,e.target.value),className:L(s?.agentName),children:[(0,j.jsx)(`option`,{value:``,children:r(`hook.selectAgentPlaceholder`)}),T.map(e=>(0,j.jsxs)(`option`,{value:e.id,children:[e.name,` (`,e.description,`)`]},e.id))]}),(0,j.jsx)(`p`,{className:`mt-1 text-xs text-dark-muted`,children:r(`hook.agentReadOnlyHint`)})]})]}),E===2&&(0,j.jsxs)(`div`,{className:`space-y-4`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldPriority`)}),(0,j.jsx)(`select`,{value:O.priority,onChange:e=>W(`priority`,e.target.value),className:L(),children:I.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 max-md:grid-cols-1`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldTimeout`)}),(0,j.jsx)(`input`,{type:`number`,value:O.timeoutMs,onChange:e=>W(`timeoutMs`,parseInt(e.target.value)||3e4),min:100,max:3e5,step:1e3,className:L()})]}),(0,j.jsxs)(`div`,{className:`flex flex-col gap-2.5`,children:[(0,j.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-dark-text`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:O.enabled,onChange:e=>W(`enabled`,e.target.checked),className:`h-3.5 w-3.5 accent-accent-blue`}),r(`hook.labelEnabled`)]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-dark-text`,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:O.failOpen,onChange:e=>W(`failOpen`,e.target.checked),className:`h-3.5 w-3.5 accent-accent-blue`}),r(`hook.failOpenLabel`)]}),(0,j.jsxs)(`label`,{className:`flex items-center gap-2 text-sm text-dark-text`,title:r(`hook.onFailureHint`),children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:O.onFailure===`block`,onChange:e=>{let t=e.target.checked;M(e=>({...e,onFailure:t?`block`:`fail-open`,failOpen:!t&&e.failOpen})),h()},className:`h-3.5 w-3.5 accent-accent-blue`}),r(`hook.onFailureLabel`)]})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.fieldToolFilter`)}),(0,j.jsx)(`input`,{value:O.matcherToolNamePattern,onChange:e=>W(`matcherToolNamePattern`,e.target.value),placeholder:`Bash.*|FileWrite.*`,className:`font-mono ${L()}`})]}),O.events.some(e=>e.includes(`STATE`))&&(0,j.jsxs)(`div`,{className:`grid grid-cols-2 gap-3 max-md:grid-cols-1`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:`From State`}),(0,j.jsx)(`input`,{value:O.matcherFromState,onChange:e=>W(`matcherFromState`,e.target.value),className:L()})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:`To State`}),(0,j.jsx)(`input`,{value:O.matcherToState,onChange:e=>W(`matcherToState`,e.target.value),className:L()})]})]}),c&&(0,j.jsxs)(`div`,{className:`rounded-lg border border-dark-border bg-dark-surface p-3`,children:[(0,j.jsx)(`div`,{className:`mb-2 text-xs font-medium text-dark-text`,children:r(`hook.dryRunResultTitle`)}),(0,j.jsxs)(`div`,{className:`space-y-1 text-xs`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-dark-muted`,children:r(`hook.dryRunDecision`)}),(0,j.jsx)(`span`,{className:String(c.decision).toUpperCase()===`ALLOW`?`text-accent-green`:String(c.decision).toUpperCase()===`DENY`?`text-accent-red`:`text-accent-yellow`,children:c.decision}),typeof c.durationMs==`number`&&(0,j.jsxs)(`span`,{className:`ms-2 text-dark-muted`,children:[c.durationMs,`ms`]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-dark-muted`,children:r(`hook.dryRunReason`)}),(0,j.jsx)(`span`,{className:`text-dark-text`,children:c.reason})]}),c.contextOutput&&(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`span`,{className:`text-dark-muted`,children:r(`hook.dryRunOutput`)}),(0,j.jsx)(`pre`,{className:`mt-1 max-h-40 overflow-auto whitespace-pre-wrap break-all font-mono text-meta text-dark-text`,children:c.contextOutput})]})]})]}),(0,j.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.dryRunSampleTool`)}),(0,j.jsx)(`input`,{value:z,onChange:e=>B(e.target.value),placeholder:`bash / write_file / apply_patch`,className:`font-mono ${L()}`})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{className:R,children:r(`hook.dryRunSampleInput`)}),(0,j.jsx)(`input`,{value:V,onChange:e=>H(e.target.value),placeholder:`{"command":"rm -rf /tmp/x"}`,className:`font-mono ${L()}`})]})]}),(0,j.jsxs)(`button`,{onClick:J,className:`inline-flex items-center gap-1.5 rounded-lg border border-dark-border bg-dark-surface px-3 py-1.5 text-xs text-dark-text transition-colors hover:bg-dark-hover`,children:[(0,j.jsx)(_,{size:12}),` `,r(`hook.dryRunButton`)]})]})]}),(0,j.jsxs)(`div`,{className:`flex flex-shrink-0 items-center justify-between border-t border-dark-border px-4 py-3`,children:[(0,j.jsx)(`div`,{className:`flex gap-2`,children:E>0&&(0,j.jsx)(w,{size:`sm`,onClick:()=>D(E-1),leftIcon:(0,j.jsx)(m,{size:14}),children:r(`hook.prevStep`)})}),(0,j.jsxs)(`div`,{className:`flex gap-2`,children:[(0,j.jsx)(w,{size:`sm`,onClick:d,children:r(`common.cancel`)}),E<2?(0,j.jsx)(w,{size:`sm`,variant:`accent`,onClick:()=>D(E+1),rightIcon:(0,j.jsx)(i,{size:14}),children:r(`hook.nextStep`)}):(0,j.jsx)(w,{size:`sm`,variant:`accent`,onClick:q,children:r(a?`hook.saveChanges`:`hook.createRule`)})]})]})]})]}):null}function B({stats:e}){let{t}=x();if(!e)return null;let n=[{id:`total`,label:t(`hook.statTotal`),value:e.totalHooks,icon:u,iconWrap:`bg-accent-blue/15 text-accent-blue`},{id:`enabled`,label:t(`common.enabled`),value:e.enabledCount,icon:b,iconWrap:`bg-accent-green/15 text-accent-green`},{id:`disabled`,label:t(`common.disabled`),value:e.disabledCount,icon:c,iconWrap:`bg-dark-hover text-dark-muted`}];return(0,j.jsx)(`div`,{className:`grid grid-cols-3 gap-3 max-md:grid-cols-1`,children:n.map(e=>{let t=e.icon;return(0,j.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-dark-border bg-dark-surface px-4 py-3`,children:[(0,j.jsx)(`span`,{className:`flex h-9 w-9 shrink-0 items-center justify-center rounded-lg ${e.iconWrap}`,children:(0,j.jsx)(t,{size:18})}),(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`div`,{className:`text-xl font-bold text-dark-text`,children:e.value}),(0,j.jsx)(`div`,{className:`text-xs text-dark-muted`,children:e.label})]})]},e.id)})})}var V={safety:{Icon:a,cls:`text-accent-red`},quality:{Icon:t,cls:`text-accent-blue`},audit:{Icon:s,cls:`text-accent-purple`}},H={Icon:s,cls:`text-dark-muted`},U=[`safety`,`quality`,`audit`];function W({templates:e,existingNames:t,onPick:r}){let{t:a}=x(),[o,s]=(0,k.useState)(!0),c=Array.isArray(e)?e:[],l=(0,k.useMemo)(()=>{let e=e=>{let t=U.indexOf(e);return t===-1?U.length:t};return[...c].sort((t,n)=>e(t.category)-e(n.category))},[c]);if(c.length===0)return null;let u=new Set(t);return(0,j.jsxs)(`section`,{className:`mt-4 min-w-0 rounded-xl border border-dark-border bg-dark-surface px-4 py-3`,children:[(0,j.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,j.jsxs)(`div`,{className:`min-w-0`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-dark-text`,children:a(`hook.templatesTitle`)}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-dark-muted`,children:a(`hook.templatesDesc`)})]}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>s(e=>!e),"aria-expanded":o,className:`shrink-0 rounded-lg p-1.5 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,title:a(o?`common.collapse`:`common.expand`),children:o?(0,j.jsx)(n,{size:16}):(0,j.jsx)(i,{size:16})})]}),o&&(0,j.jsx)(`div`,{className:`mt-3 grid grid-cols-1 gap-2 md:grid-cols-2 xl:grid-cols-3`,children:l.map(e=>{let{Icon:t,cls:n}=V[e.category]??H,i=a(`hook.template.${e.id}.title`),o=a(`hook.template.${e.id}.desc`),s=u.has(e.id);return(0,j.jsxs)(`button`,{type:`button`,onClick:()=>r(e),className:`group flex flex-col rounded-lg border border-dark-border bg-dark-bg p-2.5 text-start transition-colors hover:border-accent-blue/40 hover:bg-dark-hover`,children:[(0,j.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,j.jsx)(t,{size:13,className:n}),(0,j.jsx)(`span`,{className:`text-meta uppercase tracking-wider text-dark-muted`,children:a(`hook.templateCategory.${e.category}`)}),s&&(0,j.jsx)(`span`,{className:`ms-auto rounded bg-dark-raised px-1.5 text-badge text-dark-muted`,children:a(`hook.templateExists`)})]}),(0,j.jsx)(`div`,{className:`mt-1 text-sm font-medium text-dark-text`,children:i}),(0,j.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs leading-relaxed text-dark-muted`,children:o}),(0,j.jsx)(`div`,{className:`mt-2 text-xs text-accent-blue/80 transition-colors group-hover:text-accent-blue`,children:a(`hook.templateUse`)})]},e.id)})})]})}function G(){let{t:e}=x(),[t,n]=(0,k.useState)(null),[r,i]=(0,k.useState)(!1),{rules:a,templates:s,stats:c,events:u,agents:d,loading:p,error:m,formOpen:_,loadAll:v,openForm:y,openFormFromTemplate:b,clearError:S}=A();(0,k.useEffect)(()=>{v()},[]);let C=(0,k.useCallback)(async()=>{let e=await T.hooks.export();if(e.success&&e.data){let t=new Blob([JSON.stringify(e.data,null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=`hooks-export.json`,r.click(),URL.revokeObjectURL(n)}},[]),E=(0,k.useCallback)(()=>{let e=document.createElement(`input`);e.type=`file`,e.accept=`.json`,e.onchange=async e=>{let t=e.target.files?.[0];if(!t)return;let r=await t.text();try{let e=JSON.parse(r);n({fileName:t.name,data:e})}catch(e){console.error(`Import failed:`,e)}},e.click()},[]),O=(0,k.useCallback)(async e=>{if(t){i(!0);try{(await T.hooks.import({...t.data,mergeMode:e})).success&&(n(null),v())}catch(e){console.error(`Import failed:`,e)}finally{i(!1)}}},[t,v]);return(0,j.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col bg-dark-bg text-dark-text`,children:[(0,j.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-dark-border px-6 py-4 max-md:px-3 max-md:py-3`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h2`,{className:`text-base font-semibold text-dark-text`,children:e(`hook.configTitle`)}),(0,j.jsx)(`p`,{className:`mt-0.5 text-xs text-dark-muted`,children:e(`hook.configDesc`)})]}),(0,j.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,j.jsx)(`button`,{onClick:v,title:e(`common.refresh`),className:`rounded-lg p-2 text-dark-muted transition-colors hover:bg-dark-hover hover:text-dark-text`,children:(0,j.jsx)(f,{size:16,className:p?`animate-spin`:``})}),(0,j.jsx)(w,{onClick:E,leftIcon:(0,j.jsx)(h,{size:14}),children:e(`hook.import`)}),(0,j.jsx)(w,{onClick:C,leftIcon:(0,j.jsx)(o,{size:14}),children:e(`hook.export`)}),(0,j.jsx)(w,{variant:`accent`,onClick:()=>y(),leftIcon:(0,j.jsx)(l,{size:14}),children:e(`hook.newRule`)})]})]}),(0,j.jsxs)(`div`,{className:`flex-1 min-h-0 overflow-auto custom-scrollbar px-6 py-4 max-md:px-3 max-md:py-3`,children:[m&&(0,j.jsxs)(`div`,{className:`mb-3 flex items-center justify-between rounded-lg border border-accent-red/40 bg-accent-red/10 px-4 py-2 text-sm text-accent-red`,children:[(0,j.jsx)(`span`,{children:m}),(0,j.jsx)(`button`,{onClick:S,className:`text-accent-red/70 transition-colors hover:text-accent-red`,children:(0,j.jsx)(g,{size:16})})]}),(0,j.jsx)(B,{stats:c}),(0,j.jsx)(W,{templates:s,existingNames:a.map(e=>e.name),onPick:t=>b(t,e(`hook.template.${t.id}.desc`))}),(0,j.jsxs)(`section`,{className:`mt-4 min-w-0 rounded-xl border border-dark-border bg-dark-surface p-4`,children:[(0,j.jsxs)(`div`,{className:`mb-3 flex items-center justify-between`,children:[(0,j.jsx)(`h3`,{className:`text-sm font-semibold text-dark-text`,children:e(`hook.ruleList`)}),(0,j.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e(`hook.ruleCount`,{n:a.length})})]}),p&&a.length===0?(0,j.jsx)(`div`,{className:`flex h-[520px] items-center justify-center text-dark-muted`,children:e(`common.loading`)}):(0,j.jsx)(`div`,{className:`min-h-[520px]`,children:(0,j.jsx)(P,{rules:a,onEdit:e=>y(e)})})]})]}),(0,j.jsx)(z,{isOpen:_,events:u,agents:d}),(0,j.jsx)(D,{isOpen:t!==null,onClose:()=>{r||n(null)},title:e(`hook.importTitle`),size:`sm`,children:(0,j.jsxs)(`div`,{className:`space-y-4`,children:[t&&(0,j.jsxs)(`p`,{className:`text-sm leading-relaxed text-dark-muted`,children:[(0,j.jsx)(`span`,{className:`text-dark-text`,children:t.fileName}),(0,j.jsx)(`br`,{}),e(`hook.importDesc`)]}),(0,j.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[(0,j.jsx)(w,{variant:`ghost`,disabled:r,onClick:()=>n(null),"data-autofocus":!0,children:e(`common.cancel`)}),(0,j.jsx)(w,{variant:`danger`,disabled:r,onClick:()=>void O(`replace`),children:e(`hook.importReplace`)}),(0,j.jsx)(w,{variant:`accent`,loading:r,onClick:()=>void O(`merge`),children:e(`hook.importMerge`)})]})]})})]})}export{G as HookConfigView};
@@ -0,0 +1 @@
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{Kr as t,Wt as n,br as r,ii as i,it as a,lr as o,qr as s,t as c,un as l,v as u}from"./icons-CittejKL.js";import{t as d}from"./useTranslation-2BGEBvJE.js";import{I as f}from"./markdown-DZQBOzWk.js";import{H as p,U as m,Y as h}from"./index-CxrzleFg.js";var g=e(i(),1),_=f(),v={pending:`bg-amber-500/15 text-amber-600 dark:text-amber-400`,processing:`bg-blue-500/15 text-blue-600 dark:text-blue-400`,deferred:`bg-purple-500/15 text-purple-600 dark:text-purple-400`,done:`bg-green-500/15 text-green-600 dark:text-green-400`},y={critical:`bg-red-500/15 text-red-600 dark:text-red-400`,normal:`bg-gray-500/15 text-gray-600 dark:text-gray-400`,low:`bg-gray-500/10 text-gray-500 dark:text-gray-500`};function b({msg:e}){let{wakeup:t}=e;return t.mode===`now`?(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded px-1.5 py-0.5 text-[10px] ${y[t.urgency]||y.normal}`,children:[(0,_.jsx)(c,{size:10}),` now`]}):(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-1 rounded bg-gray-500/10 px-1.5 py-0.5 text-[10px] text-gray-500`,children:[(0,_.jsx)(s,{size:10}),` drain`]})}function x({msg:e,onDelete:t}){let{t:i}=d(),a=e.resultSummary||(e.wakeup.reason?`唤醒理由:${e.wakeup.reason}`:``);return(0,_.jsxs)(`div`,{className:`group flex items-start gap-3 rounded-lg border border-transparent px-3 py-2.5 hover:bg-black/5 dark:hover:bg-white/5`,children:[(0,_.jsx)(`div`,{className:`mt-0.5 shrink-0`,children:e.status===`done`?(0,_.jsx)(r,{size:16,className:`text-green-500`}):(0,_.jsx)(n,{size:16,className:`text-gray-400`})}),(0,_.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,_.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,_.jsx)(`span`,{className:`font-medium text-sm text-light-text dark:text-dark-text`,children:e.kind}),(0,_.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${v[e.status]||``}`,children:e.status}),e.status!==`done`&&(0,_.jsx)(b,{msg:e}),(0,_.jsx)(`span`,{className:`text-xs text-dark-muted`,children:e.from})]}),a&&(0,_.jsx)(`p`,{className:`mt-1 truncate text-xs text-dark-muted`,title:a,children:a}),(0,_.jsxs)(`div`,{className:`mt-0.5 flex items-center gap-2 text-[10px] text-gray-400`,children:[(0,_.jsxs)(`span`,{className:`inline-flex items-center gap-0.5`,children:[(0,_.jsx)(o,{size:9}),` `,m(new Date(e.createdAt),`MM-dd HH:mm`)]}),e.deferCount>0&&(0,_.jsxs)(`span`,{children:[`defer ×`,e.deferCount]})]})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),className:`shrink-0 rounded p-1 text-gray-400 opacity-0 transition-opacity hover:bg-red-500/10 hover:text-red-500 group-hover:opacity-100`,title:i(`common.delete`,`删除`),children:(0,_.jsx)(u,{size:14})})]})}function S(){let{t:e}=d(),{stats:n,messages:i,lastWake:s,loading:c,error:u,fetchInbox:f,removeMessage:m}=p();(0,g.useEffect)(()=>{f();let e=setInterval(()=>void f(),3e4);return()=>clearInterval(e)},[f]);let v=[{label:e(`inbox.pending`,`待消化`),value:n.pending,icon:t,accent:`text-amber-500`},{label:e(`inbox.deferred`,`已延后`),value:n.deferred,icon:o,accent:`text-purple-500`},{label:e(`inbox.done`,`已消化`),value:n.done,icon:r,accent:`text-green-500`}];return(0,_.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,_.jsxs)(`div`,{className:`flex items-center justify-between border-b border-black/10 px-4 py-3 dark:border-white/10`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,_.jsx)(l,{size:18,className:`text-dark-muted`}),(0,_.jsx)(`h2`,{className:`font-semibold text-sm`,children:e(`inbox.title`,`收件箱`)}),s&&(0,_.jsxs)(`span`,{className:`rounded bg-blue-500/10 px-1.5 py-0.5 text-[10px] text-blue-500`,children:[`wake: `,s.verdict]})]}),(0,_.jsx)(`button`,{type:`button`,onClick:()=>void f(),className:`rounded p-1.5 text-dark-muted hover:bg-black/5 dark:hover:bg-white/5`,title:e(`common.refresh`,`刷新`),children:(0,_.jsx)(a,{size:14,className:c?`animate-spin`:``})})]}),(0,_.jsx)(`div`,{className:`flex gap-3 px-4 py-3`,children:v.map(e=>(0,_.jsxs)(`div`,{className:`flex flex-1 items-center gap-2 rounded-lg bg-black/5 px-3 py-2 dark:bg-white/5`,children:[(0,_.jsx)(e.icon,{size:16,className:e.accent}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`div`,{className:`font-semibold text-sm leading-none`,children:e.value}),(0,_.jsx)(`div`,{className:`mt-0.5 text-[10px] text-dark-muted`,children:e.label})]})]},e.label))}),u&&(0,_.jsx)(`div`,{className:`mx-4 mb-2 rounded bg-red-500/10 px-3 py-2 text-xs text-red-500`,children:u}),(0,_.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-2 pb-4`,children:[(0,_.jsx)(h,{className:`mx-1 mb-3`}),i.length===0?(0,_.jsxs)(`div`,{className:`flex h-40 flex-col items-center justify-center gap-2 text-dark-muted`,children:[(0,_.jsx)(l,{size:28,className:`opacity-40`}),(0,_.jsx)(`p`,{className:`text-xs`,children:e(`inbox.empty`,`收件箱为空 —— 各传感器有变化时这里会出现消息`)})]}):i.map(e=>(0,_.jsx)(x,{msg:e,onDelete:e=>void m(e)},e.id))]})]})}export{S as InboxView};