pikiloom 0.4.16 → 0.4.18

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 (36) hide show
  1. package/README.md +2 -1
  2. package/dashboard/dist/assets/{AgentTab-B5tmLxa7.js → AgentTab-CDVhy5K1.js} +1 -1
  3. package/dashboard/dist/assets/{DirBrowser-CBp5nyfS.js → DirBrowser-BElI1-4D.js} +1 -1
  4. package/dashboard/dist/assets/{ExtensionsTab-w4pkrNas.js → ExtensionsTab-BB8ipJ77.js} +1 -1
  5. package/dashboard/dist/assets/{IMAccessTab-37Po5LP1.js → IMAccessTab-IZt_yXoG.js} +1 -1
  6. package/dashboard/dist/assets/{Modal-CBMO5UcS.js → Modal-C1EAGSL1.js} +1 -1
  7. package/dashboard/dist/assets/{Modals-DMlEjJUG.js → Modals-DYUV5yR9.js} +1 -1
  8. package/dashboard/dist/assets/{Select-BiSTkS_t.js → Select-BnsbE6Qv.js} +1 -1
  9. package/dashboard/dist/assets/SessionPanel-Ca_TVTT1.js +1 -0
  10. package/dashboard/dist/assets/{SystemTab-Brzt5wTT.js → SystemTab-Dk6k2OTt.js} +1 -1
  11. package/dashboard/dist/assets/{index-5Q-Q7ByM.js → index-CK-3CNRp.js} +2 -2
  12. package/dashboard/dist/assets/index-CnJsD381.js +23 -0
  13. package/dashboard/dist/assets/index-dzfjF9Js.css +1 -0
  14. package/dashboard/dist/assets/{shared-P-W1OYQ6.js → shared-CZVD0MJD.js} +1 -1
  15. package/dashboard/dist/index.html +2 -2
  16. package/dist/agent/artifacts.js +160 -0
  17. package/dist/agent/images.js +51 -24
  18. package/dist/agent/index.js +4 -2
  19. package/dist/agent/mcp/tools/workspace.js +4 -3
  20. package/dist/bot/bot.js +83 -4
  21. package/dist/bot/commands.js +48 -2
  22. package/dist/bot/menu.js +1 -0
  23. package/dist/bot/session-hub.js +1 -1
  24. package/dist/channels/dingtalk/bot.js +9 -1
  25. package/dist/channels/discord/bot.js +9 -1
  26. package/dist/channels/feishu/bot.js +8 -1
  27. package/dist/channels/slack/bot.js +9 -1
  28. package/dist/channels/telegram/bot.js +8 -1
  29. package/dist/channels/wecom/bot.js +9 -1
  30. package/dist/channels/weixin/bot.js +9 -1
  31. package/dist/cli/main.js +1 -0
  32. package/dist/dashboard/routes/sessions.js +108 -27
  33. package/package.json +2 -1
  34. package/dashboard/dist/assets/SessionPanel-BVC7kwlX.js +0 -1
  35. package/dashboard/dist/assets/index-Dw3ty4QY.js +0 -23
  36. package/dashboard/dist/assets/index-FD86DEDF.css +0 -1
@@ -1 +1 @@
1
- import{r as a,j as e,a as H}from"./react-vendor-C7Sl8SE7.js";import{c}from"./index-5Q-Q7ByM.js";function y(u,h){return!!(u&&h instanceof Node&&u.contains(h))}function M({value:u,options:h,onChange:j,className:g,placeholder:l="—",disabled:x=!1,readOnly:f=!1}){const p=h.find(t=>t.value===u),w=f||h.length<=1,[i,m]=a.useState(!1),[o,d]=a.useState(null),n=a.useRef(null),_=a.useRef(null);if(a.useEffect(()=>{if(!i)return;const t=s=>{y(n.current,s.target)||y(_.current,s.target)||m(!1)},r=s=>{s.key==="Escape"&&(s.stopPropagation(),m(!1))};return document.addEventListener("mousedown",t),document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",r,!0)}},[i]),a.useLayoutEffect(()=>{if(!i)return;const t=()=>{const r=n.current;if(!r)return;const s=r.getBoundingClientRect(),k=window.innerHeight-s.bottom-12,E=s.top-12,N=k<220&&E>k,L=Math.max(140,Math.min(260,N?E:k));d({left:s.left,top:N?Math.max(12,s.top-L-8):s.bottom+8,width:s.width,maxHeight:L})};return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[i]),w)return e.jsx("div",{className:c("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",x&&"cursor-not-allowed",g),children:e.jsx("span",{className:c("truncate",!p&&"text-fg-6"),children:p?.label||l})});const b=t=>{x||(j(t),m(!1))},v=i&&o?H.createPortal(e.jsx("div",{ref:_,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:o.left,top:o.top,width:o.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:o.maxHeight},children:h.map(t=>{const r=t.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":r,onClick:()=>b(t.value),className:c("flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",r?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:t.meta})]}),t.description&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-relaxed text-fg-5",children:t.description})]}),r&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"mt-0.5 shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},t.value)})})}),document.body):null;return e.jsxs("div",{ref:n,className:c("relative",g),children:[e.jsxs("button",{type:"button",disabled:x,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>m(t=>!t),className:c("flex h-9 w-full items-center rounded-md border border-control-border bg-control px-3 pr-8 text-left text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-control-border-h hover:bg-control-h","focus-visible:border-control-border-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:bg-panel-alt disabled:border-edge disabled:text-fg-5","disabled:shadow-none disabled:hover:border-edge disabled:hover:bg-panel-alt",i&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:c("min-w-0 flex-1 truncate",!p&&"text-fg-5"),children:p?.label||l}),e.jsx("span",{className:c("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",i&&"rotate-180"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),v]})}function P({value:u,options:h,onChange:j,renderIcon:g}){const[l,x]=a.useState(!1),[f,p]=a.useState(null),w=a.useRef(null),i=a.useRef(null);a.useEffect(()=>{if(!l)return;const o=n=>{y(w.current,n.target)||y(i.current,n.target)||x(!1)},d=n=>{n.key==="Escape"&&(n.stopPropagation(),x(!1))};return document.addEventListener("mousedown",o),document.addEventListener("keydown",d,!0),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",d,!0)}},[l]),a.useLayoutEffect(()=>{if(!l)return;const o=()=>{const d=w.current;if(!d)return;const n=d.getBoundingClientRect(),b=window.innerHeight-n.bottom-12,v=n.top-12,t=b<220&&v>b,r=Math.max(140,Math.min(260,t?v:b));p({left:n.left,top:t?Math.max(12,n.top-r-8):n.bottom+8,width:Math.max(n.width,160),maxHeight:r})};return o(),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)}},[l]);const m=l&&f?H.createPortal(e.jsx("div",{ref:i,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:f.left,top:f.top,width:f.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:f.maxHeight},children:h.map(o=>{const d=o.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":d,onClick:()=>{j(o.value),x(!1)},className:c("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors duration-200",d?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[g(o.value),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o.label}),d&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},o.value)})})}),document.body):null;return e.jsxs("div",{ref:w,className:"relative shrink-0",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":l,onClick:()=>x(o=>!o),className:c("inline-flex items-center gap-1.5 rounded-lg border border-edge bg-inset px-2 py-1.5","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",l&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[g(u),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:c("text-fg-5 transition-transform duration-200",l&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),m]})}export{P as I,M as S};
1
+ import{r as a,j as e,a as H}from"./react-vendor-C7Sl8SE7.js";import{c}from"./index-CK-3CNRp.js";function y(u,h){return!!(u&&h instanceof Node&&u.contains(h))}function M({value:u,options:h,onChange:j,className:g,placeholder:l="—",disabled:x=!1,readOnly:f=!1}){const p=h.find(t=>t.value===u),w=f||h.length<=1,[i,m]=a.useState(!1),[o,d]=a.useState(null),n=a.useRef(null),_=a.useRef(null);if(a.useEffect(()=>{if(!i)return;const t=s=>{y(n.current,s.target)||y(_.current,s.target)||m(!1)},r=s=>{s.key==="Escape"&&(s.stopPropagation(),m(!1))};return document.addEventListener("mousedown",t),document.addEventListener("keydown",r,!0),()=>{document.removeEventListener("mousedown",t),document.removeEventListener("keydown",r,!0)}},[i]),a.useLayoutEffect(()=>{if(!i)return;const t=()=>{const r=n.current;if(!r)return;const s=r.getBoundingClientRect(),k=window.innerHeight-s.bottom-12,E=s.top-12,N=k<220&&E>k,L=Math.max(140,Math.min(260,N?E:k));d({left:s.left,top:N?Math.max(12,s.top-L-8):s.bottom+8,width:s.width,maxHeight:L})};return t(),window.addEventListener("resize",t),window.addEventListener("scroll",t,!0),()=>{window.removeEventListener("resize",t),window.removeEventListener("scroll",t,!0)}},[i]),w)return e.jsx("div",{className:c("flex h-9 w-full items-center rounded-md border border-edge bg-panel-alt px-3 text-[13px] text-fg-5 shadow-none",x&&"cursor-not-allowed",g),children:e.jsx("span",{className:c("truncate",!p&&"text-fg-6"),children:p?.label||l})});const b=t=>{x||(j(t),m(!1))},v=i&&o?H.createPortal(e.jsx("div",{ref:_,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:o.left,top:o.top,width:o.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:o.maxHeight},children:h.map(t=>{const r=t.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":r,onClick:()=>b(t.value),className:c("flex w-full items-start gap-2 rounded-lg px-3 py-2 text-left text-[13px] transition-colors duration-200",r?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"min-w-0 flex-1 truncate",children:t.label}),t.meta&&e.jsx("span",{className:"shrink-0 font-mono text-[10px] text-fg-5",children:t.meta})]}),t.description&&e.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] leading-relaxed text-fg-5",children:t.description})]}),r&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"mt-0.5 shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},t.value)})})}),document.body):null;return e.jsxs("div",{ref:n,className:c("relative",g),children:[e.jsxs("button",{type:"button",disabled:x,"aria-haspopup":"listbox","aria-expanded":i,onClick:()=>m(t=>!t),className:c("flex h-9 w-full items-center rounded-md border border-control-border bg-control px-3 pr-8 text-left text-[13px] text-fg shadow-sm","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-control-border-h hover:bg-control-h","focus-visible:border-control-border-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]","disabled:cursor-not-allowed disabled:bg-panel-alt disabled:border-edge disabled:text-fg-5","disabled:shadow-none disabled:hover:border-edge disabled:hover:bg-panel-alt",i&&"border-control-border-h bg-control-h shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[e.jsx("span",{className:c("min-w-0 flex-1 truncate",!p&&"text-fg-5"),children:p?.label||l}),e.jsx("span",{className:c("pointer-events-none absolute inset-y-0 right-3 flex items-center text-fg-4 transition-transform duration-200",i&&"rotate-180"),children:e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})})]}),v]})}function P({value:u,options:h,onChange:j,renderIcon:g}){const[l,x]=a.useState(!1),[f,p]=a.useState(null),w=a.useRef(null),i=a.useRef(null);a.useEffect(()=>{if(!l)return;const o=n=>{y(w.current,n.target)||y(i.current,n.target)||x(!1)},d=n=>{n.key==="Escape"&&(n.stopPropagation(),x(!1))};return document.addEventListener("mousedown",o),document.addEventListener("keydown",d,!0),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",d,!0)}},[l]),a.useLayoutEffect(()=>{if(!l)return;const o=()=>{const d=w.current;if(!d)return;const n=d.getBoundingClientRect(),b=window.innerHeight-n.bottom-12,v=n.top-12,t=b<220&&v>b,r=Math.max(140,Math.min(260,t?v:b));p({left:n.left,top:t?Math.max(12,n.top-r-8):n.bottom+8,width:Math.max(n.width,160),maxHeight:r})};return o(),window.addEventListener("resize",o),window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("resize",o),window.removeEventListener("scroll",o,!0)}},[l]);const m=l&&f?H.createPortal(e.jsx("div",{ref:i,role:"listbox",className:"fixed z-[220] overflow-hidden rounded-xl border border-edge-h bg-[var(--th-dropdown)] p-1.5 shadow-[0_24px_64px_rgba(2,6,23,0.22)] backdrop-blur-xl",style:{left:f.left,top:f.top,width:f.width},children:e.jsx("div",{className:"overflow-y-auto",style:{maxHeight:f.maxHeight},children:h.map(o=>{const d=o.value===u;return e.jsxs("button",{type:"button",role:"option","aria-selected":d,onClick:()=>{j(o.value),x(!1)},className:c("flex w-full items-center gap-2.5 rounded-lg px-2.5 py-2 text-left text-[13px] transition-colors duration-200",d?"bg-panel text-fg shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]":"text-fg-3 hover:bg-panel-alt hover:text-fg-2"),children:[g(o.value),e.jsx("span",{className:"min-w-0 flex-1 truncate",children:o.label}),d&&e.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"shrink-0 text-fg-4",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})})]},o.value)})})}),document.body):null;return e.jsxs("div",{ref:w,className:"relative shrink-0",children:[e.jsxs("button",{type:"button","aria-haspopup":"listbox","aria-expanded":l,onClick:()=>x(o=>!o),className:c("inline-flex items-center gap-1.5 rounded-lg border border-edge bg-inset px-2 py-1.5","transition-[border-color,box-shadow,background] duration-200 outline-none","hover:border-edge-h hover:bg-panel","focus-visible:border-edge-h focus-visible:shadow-[0_0_0_4px_var(--th-glow-a)]",l&&"border-edge-h bg-panel shadow-[0_0_0_4px_var(--th-glow-a)]"),children:[g(u),e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:c("text-fg-5 transition-transform duration-200",l&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),m]})}export{P as I,M as S};
@@ -0,0 +1 @@
1
+ import{r as t,j as n}from"./react-vendor-C7Sl8SE7.js";import{c as ht,I as pt,S as ke,k as Se,a as j,u as We,d as xt,g as kt,j as St,f as bt,s as vt,M as yt}from"./index-CK-3CNRp.js";import{l as It,n as Xe,m as Tt,a as jt,b as Rt,p as wt,u as Nt,c as Ot,T as Lt,R as Mt,U as Ve,d as Ct,e as Ge,f as Et,L as At,I as Pt}from"./index-CnJsD381.js";import{M as Je,a as Ze}from"./Modal-C1EAGSL1.js";import"./router-DHISdpPk.js";import"./Select-BnsbE6Qv.js";import"./DirBrowser-BElI1-4D.js";import"./markdown-DxQYQFeH.js";import"./ExtensionsTab-BB8ipJ77.js";function Ft({snapshot:f}){const[r,h]=t.useState(f.currentIndex??0),[C,R]=t.useState(""),[x,p]=t.useState(!1),[W,k]=t.useState(null);t.useEffect(()=>{h(f.currentIndex??0),R(""),k(null)},[f.promptId,f.currentIndex]);const w=f.questions||[],v=w[r]||null,X=w.length,N=!!(v?.options&&v.options.length),d=N?!!v?.allowFreeform:!0,F=o=>{o&&(h(g=>g+1),R(""))},ne=async o=>{if(!x){p(!0),k(null);try{const g=await j.interactionSelectOption(f.promptId,o);if(!g.ok){k(g.error||"Failed to submit selection.");return}F(g.advanced)}catch(g){k(g?.message||"Network error.")}finally{p(!1)}}},O=async()=>{if(x)return;const o=C.trim();if(!o&&!v?.allowEmpty){k("Please enter a response.");return}p(!0),k(null);try{const g=await j.interactionSubmitText(f.promptId,o);if(!g.ok){k(g.error||"Failed to submit answer.");return}F(g.advanced)}catch(g){k(g?.message||"Network error.")}finally{p(!1)}},m=async()=>{if(!x){p(!0),k(null);try{const o=await j.interactionSkip(f.promptId);if(!o.ok){k(o.error||"Failed to skip.");return}F(o.advanced)}catch(o){k(o?.message||"Network error.")}finally{p(!1)}}},H=async()=>{if(!x){p(!0);try{await j.interactionCancel(f.promptId)}catch{}}},V=t.useMemo(()=>{const o=[];return f.hint&&o.push(f.hint),X>1&&o.push(`Question ${r+1} of ${X}`),o.join(" · ")||void 0},[f.hint,r,X]);return n.jsxs(Je,{open:!0,onClose:H,wide:N&&(v?.options?.length||0)>3,children:[n.jsx(Ze,{title:f.title||"Pikiloom needs your input",description:V,onClose:H}),v?n.jsxs("div",{className:"space-y-4",children:[n.jsxs("div",{children:[n.jsx("div",{className:"text-xs font-medium uppercase tracking-wide text-fg-5",children:v.header||"Question"}),n.jsx("div",{className:"mt-1 whitespace-pre-wrap text-sm leading-relaxed text-fg",children:v.prompt})]}),N&&n.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:(v.options||[]).map(o=>n.jsxs("button",{type:"button",disabled:x,onClick:()=>ne(o.value||o.label),className:ht("group rounded-lg border border-edge bg-panel-alt px-3 py-2 text-left text-sm transition","hover:border-control-border-h hover:bg-control-h hover:shadow-sm","focus:outline-none focus:ring-2 focus:ring-[var(--th-glow-a)]","disabled:cursor-not-allowed disabled:opacity-50"),children:[n.jsx("div",{className:"font-medium text-fg group-hover:text-fg",children:o.label}),o.description&&n.jsx("div",{className:"mt-0.5 text-xs leading-snug text-fg-4",children:o.description})]},o.value||o.label))}),d&&n.jsx("div",{children:n.jsx(pt,{value:C,onChange:o=>R(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.shiftKey&&!x&&(o.preventDefault(),O())},placeholder:N?"Or type a custom answer…":"Type your answer…",disabled:x,autoFocus:!N})}),W&&n.jsx("div",{className:"rounded-md border border-red-300/40 bg-red-500/10 px-3 py-2 text-xs text-red-600",children:W}),n.jsxs("div",{className:"flex items-center justify-between gap-3",children:[n.jsx("div",{className:"text-xs text-fg-5",children:x?n.jsxs("span",{className:"inline-flex items-center gap-2",children:[n.jsx(ke,{})," Submitting…"]}):n.jsxs("span",{children:["Press ",n.jsx("kbd",{className:"rounded border border-edge bg-panel-alt px-1.5 py-0.5 text-[10px] uppercase",children:"Enter"})," to send"]})}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Se,{variant:"ghost",size:"sm",onClick:m,disabled:x,children:"Skip"}),d&&n.jsx(Se,{variant:"primary",size:"sm",onClick:O,disabled:x||!C.trim()&&!v.allowEmpty,children:"Submit"})]})]})]}):n.jsxs("div",{className:"py-6 text-center text-sm text-fg-5",children:[n.jsx(ke,{className:"mr-2 inline-block"})," Waiting for the agent…"]})]})}const Pe=12,Ye=160,Ht=96,qt=20,z=new Map;function Dt(f,r){return`${f}:${r}`}function Ut(f,r){for(z.delete(f),z.set(f,r);z.size>qt;)z.delete(z.keys().next().value)}const Gt=t.memo(function({session:r,workdir:h,active:C=!0,onSessionChange:R,initialPendingPrompt:x,initialPendingImageUrls:p,onPendingPromptConsumed:W}){const k=We(e=>e.locale),w=We(e=>e.agentStatus?.agents?.find(s=>s.agent===r.agent)??null),v=w?.selectedEffort??null,X=w?.selectedModel??null,N=w?.byokProviderName??null,d=t.useMemo(()=>xt(k),[k]),F=kt(r.agent||""),ne=St(r),O=!!x||!!(p&&p.length),[m,H]=t.useState(null),[V,o]=t.useState(!O),[g,Fe]=t.useState(!1),[i,q]=t.useState(null),[G,Y]=t.useState(!1),[se,be]=t.useState(null),[et,He]=t.useState(0),[tt,ve]=t.useState(null),[le,ae]=t.useState([]),[rt,oe]=t.useState([]),[J,ye]=t.useState([]),[S,ue]=t.useState(x||null),[L,ce]=t.useState(p||[]),[nt,ie]=t.useState(null),Ie=t.useRef(null);Ie.current=nt;const[qe,D]=t.useState([]),De=t.useRef([]);De.current=qe;const Z=t.useRef(null),[st,Ue]=t.useState(null),[de,ee]=t.useState(null),[te,Te]=t.useState(""),[E,je]=t.useState(!1),lt=!!w?.capabilities?.fork,Re=t.useRef(null),U=t.useRef(p||[]),M=t.useRef(i),$e=t.useRef(G);M.current=i,$e.current=G;const A=t.useRef(null),fe=t.useRef(null),$=t.useRef(!0),B=t.useRef(!1),me=t.useRef(null),we=t.useRef(!1),Q=t.useRef(O),re=t.useRef(!1),P=t.useRef(!1),Ne=t.useRef(!1),Oe=t.useRef(!1),Be=t.useRef({model:null,effort:null}),at=t.useCallback(e=>{Be.current=e},[]);t.useEffect(()=>{Ne.current||!O||(Ne.current=!0,x&&!S&&ue(x),p&&p.length&&!L.length&&(ce(p),U.current=p),o(!1),He(e=>e+1),W?.())},[O,W]);const I=t.useCallback(()=>{ue(null),ce(e=>{for(const s of e)URL.revokeObjectURL(s);return[]}),U.current=[],ie(null)},[]),_=t.useCallback(()=>{D(e=>{if(!e.length)return e;for(const s of e)for(const l of s.imageUrls)URL.revokeObjectURL(l);return[]}),Z.current=null},[]),Qe=t.useCallback((e,s)=>{const l=!!M.current||$e.current,a=s||[];if(l){const u=`local-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;Z.current=u,D(c=>[...c,{localId:u,taskId:null,prompt:e||"",imageUrls:a}]);return}for(const u of U.current)URL.revokeObjectURL(u);Z.current=null,ue(e||null),ce(a),U.current=a,ie(null)},[]),ot=t.useCallback(e=>{const s=Z.current;if(s){Z.current=null,D(l=>{const a=l.findIndex(c=>c.localId===s);if(a<0)return l;const u=l.slice();return u[a]={...u[a],taskId:e},u});return}ie(e)},[]),ut=t.useCallback(async()=>{if(!de)return;const e=te.trim();if(e){je(!0);try{const s=await j.forkSession(h,r.agent||"",r.sessionId,de.atTurn,e,{});if(!s.ok||!s.sessionKey){je(!1);return}const[l,a]=s.sessionKey.split(":");ee(null),Te(""),R?.({agent:l,sessionId:a,workdir:h})}finally{je(!1)}}},[de,te,h,r.agent,r.sessionId,R]);Re.current=ut;const ge=t.useCallback(async(e,s={})=>{try{const l=await It({workdir:h,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:e.turnOffset,turnLimit:e.turnLimit,lastNTurns:e.lastNTurns},{force:s.force});return l.ok?Xe(l):null}catch{return null}},[h,r.agent,r.sessionId]),T=t.useCallback(async({keepOlder:e,force:s=!1,scrollToBottom:l=!1})=>{const a=r.sessionId;if(me.current===a)return!1;me.current=a;try{const u=await ge({turnOffset:0,turnLimit:Pe},{force:s});if(!u||r.sessionId!==a)return!1;if(l&&(B.current=!0),H(c=>!c||!e?u:Tt(c,u)),o(!1),re.current&&(re.current=!1,I()),P.current){const c=P.current;P.current=!1;const b=c!==!0?c.taskId:null;M.current&&(c===!0||M.current.taskId===b)&&q(null)}return!0}finally{me.current===a&&(me.current=null)}},[ge,I,r.sessionId]),he=t.useCallback(async()=>{if(!m?.hasOlder||we.current)return;const e=A.current;e&&(fe.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}),we.current=!0,Fe(!0);try{const s=await ge({turnOffset:Math.max(0,m.totalTurns-m.startTurn),turnLimit:Pe});s?H(l=>l?jt(l,s):s):fe.current=null}finally{we.current=!1,Fe(!1)}},[ge,m]),pe=t.useRef(null),K=t.useCallback(e=>{if(e?.sessionId&&e.sessionId!==r.sessionId&&(Oe.current=!0,Le.current=`${r.agent}:${e.sessionId}`,R?.({agent:r.agent||"",sessionId:e.sessionId,workdir:h})),!e){const l=pe.current;Y(!1),l==="streaming"?(re.current=!0,P.current=!0,T({keepOlder:!0,force:!0,scrollToBottom:$.current})):q(null),l==="done"?(I(),_()):l===null&&Q.current&&T({keepOlder:!0,force:!0}),l!==null&&(Q.current=!1),ve(null),be(null),ae([]),oe([]),ye([]),pe.current=null;return}if(be(e.phase),ve(e.taskId||null),ae(e.queuedTaskIds&&e.queuedTaskIds.length?e.queuedTaskIds:[]),oe(e.queuedTasks&&e.queuedTasks.length?e.queuedTasks:[]),ye(Array.isArray(e.interactions)&&e.interactions.length?e.interactions:[]),e.phase==="streaming"){if(P.current&&M.current&&M.current.taskId!==null&&M.current.taskId!==(e.taskId||null)&&!(e.text||"").trim()||q({taskId:e.taskId||null,phase:"streaming",text:e.text||"",thinking:e.thinking||"",activity:e.activity,plan:e.plan??null,model:e.model??null,effort:e.effort??null,previewMeta:e.previewMeta??null,subAgents:e.previewMeta?.subAgents??null,generatingImages:e.previewMeta?.generatingImages??0,artifacts:e.artifacts??null,startedAt:typeof e.startedAt=="number"?e.startedAt:null,error:null,question:e.question??null}),Y(!0),e.taskId&&e.taskId!==Ie.current){const a=De.current,u=a.findIndex(c=>c.taskId===e.taskId);if(u>=0){const c=a[u];for(const b of U.current)URL.revokeObjectURL(b);ue(c.prompt||null),ce(c.imageUrls),U.current=c.imageUrls,ie(e.taskId),D(b=>b.filter((mt,gt)=>gt!==u))}}$.current&&(B.current=!0)}else if(e.phase==="queued")q(null),Y(!1);else if(e.phase==="done"){Y(!1),q(b=>b?{...b,phase:"done",error:e.error??null}:e.error?{taskId:e.taskId||null,phase:"done",text:"",thinking:"",activity:"",plan:null,model:e.model??null,effort:e.effort??null,previewMeta:e.previewMeta??null,subAgents:e.previewMeta?.subAgents??null,generatingImages:e.previewMeta?.generatingImages??0,artifacts:e.artifacts??null,error:e.error}:b);const l=!!e.queuedTaskIds?.length,a=M.current,u=!!a&&Rt(a),c=!!e.incomplete&&u&&!l;pe.current!=="done"&&(l||(re.current=!0),P.current=c?!1:{taskId:e.taskId||null},T({keepOlder:!0,force:!0,scrollToBottom:$.current})),l||(Q.current=!1)}const s=new Set;if(e.taskId&&s.add(e.taskId),Array.isArray(e.queuedTaskIds))for(const l of e.queuedTaskIds)s.add(l);D(l=>{let a=!1;const u=[];for(const c of l)if(!c.taskId||s.has(c.taskId))u.push(c);else{for(const b of c.imageUrls)URL.revokeObjectURL(b);a=!0}return a?u:l}),pe.current=e.phase},[I,_,T,r.sessionId,r.agent,R,h]),_e=t.useCallback(()=>{Q.current=!0,He(e=>e+1)},[]),ct=t.useCallback(async e=>{try{await j.recallSessionMessage(e),Ie.current===e&&I(),D(s=>{let l=!1;const a=[];for(const u of s)if(u.taskId===e){for(const c of u.imageUrls)URL.revokeObjectURL(c);l=!0}else a.push(u);return l?a:s}),ae(s=>s.filter(l=>l!==e)),oe(s=>s.filter(l=>l.taskId!==e)),ve(s=>s===e?null:s)}catch{}},[I]),it=t.useCallback(async e=>{try{await j.steerSession(e)}catch{}},[]),dt=t.useCallback(async()=>{try{await j.stopSession(r.agent||"",r.sessionId)}catch{}},[r.agent,r.sessionId]),xe=Dt(r.agent||"",r.sessionId);t.useEffect(()=>{if(Oe.current){Oe.current=!1;let u=!1;return T({keepOlder:!0,force:!0}).finally(()=>{u||o(!1)}),()=>{u=!0}}let e=!1;const s=wt({workdir:h,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:0,turnLimit:Pe},{allowStale:!0}),l=O&&!Ne.current,a=s?.ok?Xe(s):z.get(xe)||null;return o(l?!1:!a),H(a),q(null),Y(!1),be(null),ae([]),oe([]),ye([]),l||(I(),_(),Q.current=!1,re.current=!1,P.current=!1),$.current=!0,B.current=!0,l||T({keepOlder:!1,force:!0}).finally(()=>{e||o(!1)}),()=>{e=!0}},[T,r.agent,r.sessionId,h,xe,I,_]),t.useEffect(()=>{m&&m.turns.length>0&&Ut(xe,m)},[xe,m]),t.useEffect(()=>{C&&T({keepOlder:!0,force:!0})},[C,T]);const Le=t.useRef(`${r.agent}:${r.sessionId}`);Le.current=`${r.agent}:${r.sessionId}`,Nt("stream-update",t.useCallback(e=>{e.key===Le.current&&K(e.snapshot??null)},[K])),t.useEffect(()=>{let e=!0;return j.getSessionStreamState(r.agent||"",r.sessionId).then(s=>{e&&K(s.state)}).catch(()=>{}),()=>{e=!1}},[K,r.agent,r.sessionId,et]),Ot(t.useCallback(()=>{j.getSessionStreamState(r.agent||"",r.sessionId).then(e=>{K(e.state)}).catch(()=>{}),T({keepOlder:!0,force:!0})},[K,r.agent,r.sessionId,T])),t.useEffect(()=>{!Q.current&&ne!=="running"&&!G&&!i&&!se&&le.length===0&&(I(),_())},[ne,G,i,se,le.length,I,_]),t.useLayoutEffect(()=>{const e=fe.current,s=A.current;!e||!s||(fe.current=null,s.scrollTop=e.scrollTop+(s.scrollHeight-e.scrollHeight))},[m?.turns.length]),t.useLayoutEffect(()=>{if(!B.current)return;const e=A.current;e&&(B.current=!1,e.scrollTop=e.scrollHeight,requestAnimationFrame(()=>{$.current&&(e.scrollTop=e.scrollHeight)}))},[m,i]),t.useLayoutEffect(()=>{if(!S)return;const e=A.current;e&&(e.scrollTop=e.scrollHeight)},[S]),t.useEffect(()=>{if(!m?.hasOlder||V||g)return;const e=A.current;e&&e.scrollHeight<=e.clientHeight+Ye&&he()},[m?.hasOlder,m?.turns.length,he,V,g]);const ft=t.useCallback(()=>{const e=A.current;if(!e)return;const s=e.scrollHeight-e.scrollTop-e.clientHeight;$.current=s<=Ht,e.scrollTop<=Ye&&he()},[he]),Me=i?.model||r.model||X||null,Ce=bt(r.agent||"",i?.effort||r.thinkingEffort||v||null,r.workflowEnabled??w?.workflowEnabled)||null,Ke=Me?vt(Me):null,Ee=yt(r,{streaming:G,hasLiveStream:!!i,streamPhase:se,queuedTaskCount:le.length}),y=m?.turns||[],Ae=t.useMemo(()=>{if(!L.length||!y.length)return!1;const e=y[y.length-1];return!e.user||(e.user.text?.trim()||"")!==(S||"").trim()?!1:e.user.blocks.filter(l=>l.type==="image").length<L.length},[y,S,L.length]),ze=t.useMemo(()=>{let e=y;if(Ae){const b=e[e.length-1];e=[...e.slice(0,-1),{...b,user:null}]}if(!i||!e.length)return e;const s=e[e.length-1];if(!s.assistant)return e;const l=S??(i.question||null),a=(i.text||"").trim(),u=s.assistant.text?.trim()||"";return(l!=null?s.user?.text?.trim()===l.trim():!!u&&!!a&&(a.startsWith(u)||u.startsWith(a)))?[...e.slice(0,-1),{...s,assistant:null}]:e},[y,i,S,Ae]);return n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[n.jsx("div",{ref:A,onScroll:ft,className:"flex-1 overflow-y-auto overscroll-contain",children:V&&!S&&!L.length&&!i?n.jsx("div",{className:"flex items-center justify-center py-20",children:n.jsx(ke,{className:"h-5 w-5 text-fg-4"})}):ze.length===0&&!S&&!L.length&&!i&&!Ee?n.jsx("div",{className:"py-20 text-center text-[13px] text-fg-5",children:d("hub.noMessages")}):n.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[(m?.hasOlder||g)&&n.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[g?n.jsx(ke,{className:"h-3 w-3 text-fg-5"}):n.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/35"}),n.jsx("span",{children:d(g?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),r.migratedFrom?.kind==="fork"&&r.migratedFrom.sessionId&&n.jsxs("button",{type:"button",onClick:()=>R?.({agent:r.migratedFrom.agent||r.agent||"",sessionId:r.migratedFrom.sessionId,workdir:h}),className:"mb-4 inline-flex items-center gap-1.5 rounded-md border border-edge bg-panel-alt px-2.5 py-1 text-[11px] text-fg-5 transition hover:border-edge-h hover:text-fg-2",title:`#${r.migratedFrom.sessionId.slice(0,8)}`,children:[n.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[n.jsx("circle",{cx:"6",cy:"6",r:"2"}),n.jsx("circle",{cx:"18",cy:"6",r:"2"}),n.jsx("circle",{cx:"12",cy:"20",r:"2"}),n.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),n.jsx("path",{d:"M12 14v4"})]}),n.jsx("span",{children:d("hub.forkBadge")}),n.jsxs("span",{className:"font-mono",children:["#",r.migratedFrom.sessionId.slice(0,8)]}),typeof r.migratedFrom.forkedAtTurn=="number"&&n.jsxs("span",{className:"text-fg-5/70",children:["· ",d("hub.forkBadgeAt").replace("{turn}",String(r.migratedFrom.forkedAtTurn+1))]})]}),ze.map((e,s)=>{const l=(m?.startTurn||0)+s;return n.jsx(Lt,{turn:e,turnIndex:l,agent:r.agent||"",meta:F,model:Ke,effort:Ce,providerName:N,t:d,workdir:h,onResend:a=>{B.current=!0,Qe(a);const u=Be.current;j.sendSessionMessage(h,r.agent||"",r.sessionId,a,{model:u.model||Me||void 0,effort:u.effort||Ce||void 0}).then(c=>{c.ok&&_e()}).catch(()=>{I()})},onEdit:a=>Ue(a),onFork:lt?a=>{Te(""),ee({atTurn:a})}:void 0},`${m?.startTurn||0}:${s}`)}),Ee&&n.jsx("div",{className:"mb-5 animate-in",children:n.jsx(Mt,{detail:Ee,t:d})}),(S||L.length>0)&&(Ae||!(S&&y.length>0&&y[y.length-1]?.user?.text?.trim()===S.trim()))&&n.jsxs("div",{className:"session-turn",children:[n.jsx(Ve,{text:S||"",blocks:L.map(e=>({type:"image",content:e})),t:d}),!i&&n.jsx("div",{className:"mt-3 mb-5 animate-in",children:n.jsx(Ct,{className:"text-fg-5"})})]}),i&&Ge(i)&&!S&&i.question&&!(y.length>0&&y[y.length-1]?.user?.text?.trim()===i.question.trim())&&n.jsx("div",{className:"session-turn",children:n.jsx(Ve,{text:i.question,t:d})}),i&&Ge(i)&&n.jsxs("div",{className:"mb-6",children:[n.jsx(Et,{agent:r.agent||"",meta:F,model:Ke,effort:Ce,providerName:N,previewMeta:i.previewMeta,liveStartedAt:i.phase==="streaming"?i.startedAt??null:null}),n.jsx(At,{stream:i,t:d,workdir:h})]}),n.jsx("div",{className:"h-4"})]})}),n.jsx(Pt,{session:r,workdir:h,onStreamQueued:_e,onSendStart:Qe,onSendTaskAssigned:ot,onSessionChange:R,t:d,streamPhase:se,streamTaskId:tt,queuedTaskIds:le,queuedTasks:rt,pendingQueuedSends:qe,onRecall:ct,onSteer:it,onStopAll:dt,editDraft:st,onEditDraftConsumed:()=>Ue(null),onSelectionChange:at}),de&&n.jsxs(Je,{open:!0,onClose:()=>{E||ee(null)},children:[n.jsx(Ze,{title:d("hub.forkPromptTitle"),description:d("hub.forkPromptHint"),onClose:()=>{E||ee(null)}}),n.jsx("textarea",{autoFocus:!0,value:te,disabled:E,onChange:e=>Te(e.target.value),onKeyDown:e=>{e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&te.trim()&&!E&&(e.preventDefault(),Re.current?.())},placeholder:d("hub.forkPromptPlaceholder"),className:"w-full min-h-[120px] resize-y rounded-md border border-edge bg-panel-alt px-3 py-2 text-[13px] leading-relaxed text-fg outline-none focus:border-edge-h"}),n.jsxs("div",{className:"mt-4 flex items-center justify-end gap-2",children:[n.jsx(Se,{variant:"ghost",disabled:E,onClick:()=>ee(null),children:d("modal.cancel")}),n.jsx(Se,{variant:"primary",disabled:E||!te.trim(),onClick:()=>{Re.current?.()},children:d(E?"hub.forkSubmitting":"hub.forkSubmit")})]})]}),C&&J.length>0&&n.jsx(Ft,{snapshot:J[J.length-1]},J[J.length-1].promptId)]})});export{Gt as SessionPanel};
@@ -1 +1 @@
1
- import{j as e,r as f}from"./react-vendor-C7Sl8SE7.js";import{H as N,c as C,J as F,u as x,d as G,a as $,k as w,R as L,x as g,y as O}from"./index-5Q-Q7ByM.js";import{S as v}from"./shared-P-W1OYQ6.js";import"./router-DHISdpPk.js";function k(s){return Number.isFinite(s??NaN)?Math.max(0,Math.min(100,Number(s))):null}function S(s){return Number.isFinite(s??NaN)?Number(s).toFixed(2):null}function z(s){return s?[s.hostName||"—",s.platform,s.arch].filter(Boolean).join(" · "):""}function E(s,r){if(!s)return[];const o=s.totalMem||0,i=s.memoryUsed||o-(s.freeMem||0),t=k(s.memoryPercent||(o>0?i/o*100:0)),a=k(s.cpuUsage?.usedPercent),d=s.loadAverage||null,c=S(d?.one),p=S(d?.five),u=S(d?.fifteen),h=k(d?d.one/Math.max(s.cpuCount||1,1)*100:null),y=[{key:"cpu",label:r("sessions.cpu"),value:a!=null?`${a.toFixed(0)}%`:`${s.cpuCount} cores`,detail:[`${s.cpuCount} cores`,s.cpuModel||""].filter(Boolean),tone:a!=null&&a>=85?"warn":"ok",progressPercent:a},...c&&p&&u?[{key:"cpu-load",label:r("system.cpuLoad"),value:`1m ${c}`,detail:[`5m ${p}`,`15m ${u}`],tone:h!=null&&h>=85?"warn":"muted",progressPercent:h}]:[],{key:"memory",label:r("sessions.memory"),value:`${F(i)} / ${F(o)}`,detail:t!=null?`${t.toFixed(0)}%`:void 0,tone:t!=null&&t>=85?"warn":"ok",progressPercent:t}];if(s.disk){const m=k(parseFloat(String(s.disk.percent).replace("%","")));y.push({key:"disk",label:r("sessions.disk"),value:`${s.disk.used} / ${s.disk.total}`,detail:s.disk.percent,tone:m!=null&&m>=85?"warn":"muted",progressPercent:m})}else if(s.battery){const m=k(parseFloat(String(s.battery.percent).replace("%","")));y.push({key:"battery",label:r("sessions.battery"),value:s.battery.percent,detail:s.battery.state,tone:m!=null&&m<=20?"warn":"muted",progressPercent:m})}return y}function W(s){return s?Array.isArray(s)?s.join(" · "):s:""}function q({items:s,loading:r,className:o}){return r?e.jsx("div",{className:C("space-y-1",o),children:Array.from({length:4},(i,t)=>e.jsxs("div",{className:"grid grid-cols-[80px_auto_1fr] items-baseline gap-x-4 py-1",children:[e.jsx(N,{className:"h-3 w-12"}),e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-3 w-28"})]},t))}):e.jsx("div",{className:C("flex flex-wrap items-baseline gap-x-5 gap-y-1.5",o),children:s.map(i=>{const t=W(i.detail);return e.jsxs("div",{className:"inline-flex items-baseline gap-1.5 whitespace-nowrap",title:t||void 0,children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-fg-5",children:i.label}),e.jsx("span",{className:"font-mono text-[12px] tabular-nums text-fg-2",children:i.value}),t&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:["· ",t]})]},i.key)})})}const B=[{key:"screenRecording",labelKey:"perm.screenRecording",reasonZh:"用于截图与界面分析",reasonEn:"For screenshots and UI inspection",guidePathKey:"perm.pathScreenRecording",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"5.5",width:"11.5",height:"10",rx:"2.4"}),e.jsx("path",{d:"m17.5 8.4 2.7-1.5v7.2l-2.7-1.5"}),e.jsx("circle",{cx:"9.75",cy:"10.5",r:"1.1",fill:"currentColor",stroke:"none"})]})},{key:"fullDiskAccess",labelKey:"perm.fullDiskAccess",reasonZh:"访问桌面、下载等受保护目录",reasonEn:"Access to Desktop, Downloads and other protected folders",guidePathKey:"perm.pathFullDiskAccess",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"6.2",y:"10.1",width:"11.6",height:"8.6",rx:"2.6"}),e.jsx("path",{d:"M9 10V7.8a3 3 0 1 1 6 0V10"}),e.jsx("circle",{cx:"12",cy:"13.5",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M12 14.6v1.8"})]})}];function H(s){return s==="zh-CN"?{introWithHost:"请在 macOS 中为 {hostApp} 开启以下权限。",intro:"请在 macOS 中开启以下权限。",status:"状态",summary:"系统位置",loading:"检查中",needsGrant:"需要授权",granted:"已授权",authorize:"授权",openSettings:"前往设置",refreshState:"刷新状态",checking:"检查中...",hostGranted:"{hostApp} 已可直接使用此权限。",hostGrantedFallback:"当前宿主应用已可直接使用此权限。",needsGrantDetail:"尚未授权,可通过右侧按钮发起系统授权。",needsSettingsDetail:"需要在系统设置中手动开启此权限。"}:{introWithHost:"Grant the following permissions to {hostApp} in macOS.",intro:"Grant the following permissions in macOS.",status:"Status",summary:"System path",loading:"Checking",needsGrant:"Needs access",granted:"Granted",authorize:"Authorize",openSettings:"Open settings",refreshState:"Refresh status",checking:"Checking...",hostGranted:"{hostApp} can use this permission now.",hostGrantedFallback:"The current host app can use this permission now.",needsGrantDetail:"Access has not been granted yet. Use the button on the right to trigger the macOS prompt.",needsSettingsDetail:"This permission needs to be enabled manually in System Settings."}}function I(){const s=x(n=>n.state),r=x(n=>n.locale),o=x(n=>n.reload),i=x(n=>n.toast),t=f.useMemo(()=>G(r),[r]),a=H(r),d=s?.permissions||{},c=s?.hostApp||null,p=!s,[u,h]=f.useState(null),y=f.useMemo(()=>B.map(n=>({...n,permission:d[n.key]})),[d]),m=f.useCallback(async n=>{if(!u){h(n);try{const l=await $.requestPermission(n);if(!l.ok){i(l.error||t("perm.requestFailed"),!1);return}l.action==="already_granted"?i(t("perm.alreadyGranted")):l.action==="prompted"?i(t("perm.promptOpened")):i(t("perm.settingsOpened")),await o()}catch(l){i(l instanceof Error?l.message:t("perm.requestFailed"),!1)}finally{h(l=>l===n?null:l)}}},[o,u,t,i]),M=f.useCallback(async()=>{await o()},[o]);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:c?a.introWithHost.replace("{hostApp}",c):a.intro})}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>{M()},children:a.refreshState})]}),e.jsx(L,{children:y.map(n=>{const l=n.permission,j=!!l?.granted,P=!!l&&l.checkable,A=p?a.loading:j?a.granted:a.needsGrant,D=p?"idle":j?"ok":"warn",b=p?a.loading:j?c?a.hostGranted.replace("{hostApp}",c):a.hostGrantedFallback:P?a.needsGrantDetail:a.needsSettingsDetail,R=p?a.checking:P?a.authorize:a.openSettings;return e.jsxs(g,{children:[e.jsx(g.Lead,{icon:n.icon,title:t(n.labelKey),subtitle:r==="zh-CN"?n.reasonZh:n.reasonEn}),e.jsx(g.Status,{children:e.jsx(O,{state:D,label:A})}),e.jsx(g.Field,{children:t(n.guidePathKey)}),e.jsx(g.Action,{children:!j&&e.jsx(w,{variant:"primary",size:"sm",disabled:p||!!u,onClick:()=>{m(n.key)},children:u===n.key?a.checking:R})}),b&&b!==A&&e.jsx(g.Description,{children:b})]},n.key)})})]})}function _({onOpenWorkdir:s}){const r=x(c=>c.state),o=x(c=>c.host),i=x(c=>c.locale),t=f.useMemo(()=>G(i),[i]),a=r?.bot?.workdir||r?.runtimeWorkdir||r?.config.workdir||"",d=z(o);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsx(v,{className:"!p-3.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("config.workdir")})}),e.jsx("div",{className:"mt-0.5 break-all font-mono text-[12px] leading-relaxed text-fg-2",children:a||t("sidebar.notSet")})]}),e.jsx(w,{variant:"outline",size:"sm",onClick:s,children:t("sidebar.switchDir")})]})}),e.jsxs(v,{className:"space-y-2 !p-3.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("app.systemInfo")}),e.jsx("span",{className:"truncate text-[11px] text-fg-5",children:d||t("status.loading")})]}),e.jsxs("div",{className:"text-[11px] text-fg-5",children:[r?.version?`Pikiloom v${r.version}`:"Pikiloom",r?.nodeVersion?` · Node ${r.nodeVersion}`:""]})]}),e.jsx(q,{items:E(o,t),loading:!o})]}),e.jsxs(v,{className:"space-y-2 !p-3.5",children:[e.jsx("div",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("tab.permissions")}),e.jsx(I,{})]})]})}export{_ as SystemTab};
1
+ import{j as e,r as f}from"./react-vendor-C7Sl8SE7.js";import{H as N,c as C,J as F,u as x,d as G,a as $,k as w,R as L,x as g,y as O}from"./index-CK-3CNRp.js";import{S as v}from"./shared-CZVD0MJD.js";import"./router-DHISdpPk.js";function k(s){return Number.isFinite(s??NaN)?Math.max(0,Math.min(100,Number(s))):null}function S(s){return Number.isFinite(s??NaN)?Number(s).toFixed(2):null}function z(s){return s?[s.hostName||"—",s.platform,s.arch].filter(Boolean).join(" · "):""}function E(s,r){if(!s)return[];const o=s.totalMem||0,i=s.memoryUsed||o-(s.freeMem||0),t=k(s.memoryPercent||(o>0?i/o*100:0)),a=k(s.cpuUsage?.usedPercent),d=s.loadAverage||null,c=S(d?.one),p=S(d?.five),u=S(d?.fifteen),h=k(d?d.one/Math.max(s.cpuCount||1,1)*100:null),y=[{key:"cpu",label:r("sessions.cpu"),value:a!=null?`${a.toFixed(0)}%`:`${s.cpuCount} cores`,detail:[`${s.cpuCount} cores`,s.cpuModel||""].filter(Boolean),tone:a!=null&&a>=85?"warn":"ok",progressPercent:a},...c&&p&&u?[{key:"cpu-load",label:r("system.cpuLoad"),value:`1m ${c}`,detail:[`5m ${p}`,`15m ${u}`],tone:h!=null&&h>=85?"warn":"muted",progressPercent:h}]:[],{key:"memory",label:r("sessions.memory"),value:`${F(i)} / ${F(o)}`,detail:t!=null?`${t.toFixed(0)}%`:void 0,tone:t!=null&&t>=85?"warn":"ok",progressPercent:t}];if(s.disk){const m=k(parseFloat(String(s.disk.percent).replace("%","")));y.push({key:"disk",label:r("sessions.disk"),value:`${s.disk.used} / ${s.disk.total}`,detail:s.disk.percent,tone:m!=null&&m>=85?"warn":"muted",progressPercent:m})}else if(s.battery){const m=k(parseFloat(String(s.battery.percent).replace("%","")));y.push({key:"battery",label:r("sessions.battery"),value:s.battery.percent,detail:s.battery.state,tone:m!=null&&m<=20?"warn":"muted",progressPercent:m})}return y}function W(s){return s?Array.isArray(s)?s.join(" · "):s:""}function q({items:s,loading:r,className:o}){return r?e.jsx("div",{className:C("space-y-1",o),children:Array.from({length:4},(i,t)=>e.jsxs("div",{className:"grid grid-cols-[80px_auto_1fr] items-baseline gap-x-4 py-1",children:[e.jsx(N,{className:"h-3 w-12"}),e.jsx(N,{className:"h-3 w-24"}),e.jsx(N,{className:"h-3 w-28"})]},t))}):e.jsx("div",{className:C("flex flex-wrap items-baseline gap-x-5 gap-y-1.5",o),children:s.map(i=>{const t=W(i.detail);return e.jsxs("div",{className:"inline-flex items-baseline gap-1.5 whitespace-nowrap",title:t||void 0,children:[e.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.12em] text-fg-5",children:i.label}),e.jsx("span",{className:"font-mono text-[12px] tabular-nums text-fg-2",children:i.value}),t&&e.jsxs("span",{className:"text-[11px] text-fg-5",children:["· ",t]})]},i.key)})})}const B=[{key:"screenRecording",labelKey:"perm.screenRecording",reasonZh:"用于截图与界面分析",reasonEn:"For screenshots and UI inspection",guidePathKey:"perm.pathScreenRecording",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"4",y:"5.5",width:"11.5",height:"10",rx:"2.4"}),e.jsx("path",{d:"m17.5 8.4 2.7-1.5v7.2l-2.7-1.5"}),e.jsx("circle",{cx:"9.75",cy:"10.5",r:"1.1",fill:"currentColor",stroke:"none"})]})},{key:"fullDiskAccess",labelKey:"perm.fullDiskAccess",reasonZh:"访问桌面、下载等受保护目录",reasonEn:"Access to Desktop, Downloads and other protected folders",guidePathKey:"perm.pathFullDiskAccess",icon:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("rect",{x:"6.2",y:"10.1",width:"11.6",height:"8.6",rx:"2.6"}),e.jsx("path",{d:"M9 10V7.8a3 3 0 1 1 6 0V10"}),e.jsx("circle",{cx:"12",cy:"13.5",r:"0.9",fill:"currentColor",stroke:"none"}),e.jsx("path",{d:"M12 14.6v1.8"})]})}];function H(s){return s==="zh-CN"?{introWithHost:"请在 macOS 中为 {hostApp} 开启以下权限。",intro:"请在 macOS 中开启以下权限。",status:"状态",summary:"系统位置",loading:"检查中",needsGrant:"需要授权",granted:"已授权",authorize:"授权",openSettings:"前往设置",refreshState:"刷新状态",checking:"检查中...",hostGranted:"{hostApp} 已可直接使用此权限。",hostGrantedFallback:"当前宿主应用已可直接使用此权限。",needsGrantDetail:"尚未授权,可通过右侧按钮发起系统授权。",needsSettingsDetail:"需要在系统设置中手动开启此权限。"}:{introWithHost:"Grant the following permissions to {hostApp} in macOS.",intro:"Grant the following permissions in macOS.",status:"Status",summary:"System path",loading:"Checking",needsGrant:"Needs access",granted:"Granted",authorize:"Authorize",openSettings:"Open settings",refreshState:"Refresh status",checking:"Checking...",hostGranted:"{hostApp} can use this permission now.",hostGrantedFallback:"The current host app can use this permission now.",needsGrantDetail:"Access has not been granted yet. Use the button on the right to trigger the macOS prompt.",needsSettingsDetail:"This permission needs to be enabled manually in System Settings."}}function I(){const s=x(n=>n.state),r=x(n=>n.locale),o=x(n=>n.reload),i=x(n=>n.toast),t=f.useMemo(()=>G(r),[r]),a=H(r),d=s?.permissions||{},c=s?.hostApp||null,p=!s,[u,h]=f.useState(null),y=f.useMemo(()=>B.map(n=>({...n,permission:d[n.key]})),[d]),m=f.useCallback(async n=>{if(!u){h(n);try{const l=await $.requestPermission(n);if(!l.ok){i(l.error||t("perm.requestFailed"),!1);return}l.action==="already_granted"?i(t("perm.alreadyGranted")):l.action==="prompted"?i(t("perm.promptOpened")):i(t("perm.settingsOpened")),await o()}catch(l){i(l instanceof Error?l.message:t("perm.requestFailed"),!1)}finally{h(l=>l===n?null:l)}}},[o,u,t,i]),M=f.useCallback(async()=>{await o()},[o]);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx("div",{className:"min-w-0 flex-1",children:e.jsx("div",{className:"text-[13px] leading-relaxed text-fg-4",children:c?a.introWithHost.replace("{hostApp}",c):a.intro})}),e.jsx(w,{variant:"outline",size:"sm",onClick:()=>{M()},children:a.refreshState})]}),e.jsx(L,{children:y.map(n=>{const l=n.permission,j=!!l?.granted,P=!!l&&l.checkable,A=p?a.loading:j?a.granted:a.needsGrant,D=p?"idle":j?"ok":"warn",b=p?a.loading:j?c?a.hostGranted.replace("{hostApp}",c):a.hostGrantedFallback:P?a.needsGrantDetail:a.needsSettingsDetail,R=p?a.checking:P?a.authorize:a.openSettings;return e.jsxs(g,{children:[e.jsx(g.Lead,{icon:n.icon,title:t(n.labelKey),subtitle:r==="zh-CN"?n.reasonZh:n.reasonEn}),e.jsx(g.Status,{children:e.jsx(O,{state:D,label:A})}),e.jsx(g.Field,{children:t(n.guidePathKey)}),e.jsx(g.Action,{children:!j&&e.jsx(w,{variant:"primary",size:"sm",disabled:p||!!u,onClick:()=>{m(n.key)},children:u===n.key?a.checking:R})}),b&&b!==A&&e.jsx(g.Description,{children:b})]},n.key)})})]})}function _({onOpenWorkdir:s}){const r=x(c=>c.state),o=x(c=>c.host),i=x(c=>c.locale),t=f.useMemo(()=>G(i),[i]),a=r?.bot?.workdir||r?.runtimeWorkdir||r?.config.workdir||"",d=z(o);return e.jsxs("div",{className:"animate-in space-y-3",children:[e.jsx(v,{className:"!p-3.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"flex items-baseline gap-2",children:e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("config.workdir")})}),e.jsx("div",{className:"mt-0.5 break-all font-mono text-[12px] leading-relaxed text-fg-2",children:a||t("sidebar.notSet")})]}),e.jsx(w,{variant:"outline",size:"sm",onClick:s,children:t("sidebar.switchDir")})]})}),e.jsxs(v,{className:"space-y-2 !p-3.5",children:[e.jsxs("div",{className:"flex flex-wrap items-baseline justify-between gap-x-3 gap-y-0.5",children:[e.jsxs("div",{className:"flex items-baseline gap-2 min-w-0",children:[e.jsx("span",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("app.systemInfo")}),e.jsx("span",{className:"truncate text-[11px] text-fg-5",children:d||t("status.loading")})]}),e.jsxs("div",{className:"text-[11px] text-fg-5",children:[r?.version?`Pikiloom v${r.version}`:"Pikiloom",r?.nodeVersion?` · Node ${r.nodeVersion}`:""]})]}),e.jsx(q,{items:E(o,t),loading:!o})]}),e.jsxs(v,{className:"space-y-2 !p-3.5",children:[e.jsx("div",{className:"text-[13px] font-semibold tracking-tight text-fg",children:t("tab.permissions")}),e.jsx(I,{})]})]})}export{_ as SystemTab};