pikiloop 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +353 -0
- package/README.v2.md +287 -0
- package/README.zh-CN.md +352 -0
- package/dashboard/dist/assets/AgentTab-UZPIhlkr.js +1 -0
- package/dashboard/dist/assets/DirBrowser-Ckcmi-Pi.js +1 -0
- package/dashboard/dist/assets/ExtensionsTab-KZhEDrdu.js +1 -0
- package/dashboard/dist/assets/IMAccessTab-Bd_IY1GQ.js +1 -0
- package/dashboard/dist/assets/Modal-CTeL0y7P.js +1 -0
- package/dashboard/dist/assets/Modals-axftHasy.js +1 -0
- package/dashboard/dist/assets/Select-C8tOdPhe.js +1 -0
- package/dashboard/dist/assets/SessionPanel-C1geSRxw.js +1 -0
- package/dashboard/dist/assets/SystemTab-DBDkaPiO.js +1 -0
- package/dashboard/dist/assets/anthropic-BAdojD7P.ico +0 -0
- package/dashboard/dist/assets/codex-DYadqqp0.png +0 -0
- package/dashboard/dist/assets/deepseek-BeYNZEk0.ico +0 -0
- package/dashboard/dist/assets/doubao-DloFDuFR.png +0 -0
- package/dashboard/dist/assets/feishu-C4OMrjCW.ico +0 -0
- package/dashboard/dist/assets/gemini-BYkEpiWr.svg +1 -0
- package/dashboard/dist/assets/hermes-BAarh-tH.png +0 -0
- package/dashboard/dist/assets/index-CpM4CqZJ.js +23 -0
- package/dashboard/dist/assets/index-DXSohzrE.js +3 -0
- package/dashboard/dist/assets/index-reSbuley.css +1 -0
- package/dashboard/dist/assets/markdown-DxQYQFeH.js +29 -0
- package/dashboard/dist/assets/minimax-PuEGTfrF.ico +0 -0
- package/dashboard/dist/assets/mlx-DhWwjtMw.png +0 -0
- package/dashboard/dist/assets/ollama-Bt9O-2K_.png +0 -0
- package/dashboard/dist/assets/openrouter-CsJ_bD5Q.ico +0 -0
- package/dashboard/dist/assets/playwright-BldPFZgC.ico +0 -0
- package/dashboard/dist/assets/qwen-xykkX0_y.png +0 -0
- package/dashboard/dist/assets/react-vendor-C7Sl8SE7.js +9 -0
- package/dashboard/dist/assets/router-DHISdpPk.js +3 -0
- package/dashboard/dist/assets/shared-BIP_4k4I.js +1 -0
- package/dashboard/dist/favicon.svg +28 -0
- package/dashboard/dist/index.html +17 -0
- package/dist/agent/acp-client.js +261 -0
- package/dist/agent/auto-update.js +432 -0
- package/dist/agent/await-resume.js +50 -0
- package/dist/agent/cli/auth.js +325 -0
- package/dist/agent/cli/catalog.js +40 -0
- package/dist/agent/cli/detector.js +136 -0
- package/dist/agent/cli/index.js +7 -0
- package/dist/agent/cli/registry.js +33 -0
- package/dist/agent/driver.js +39 -0
- package/dist/agent/drivers/claude-tui.js +2297 -0
- package/dist/agent/drivers/claude.js +2689 -0
- package/dist/agent/drivers/codex.js +2210 -0
- package/dist/agent/drivers/gemini.js +1059 -0
- package/dist/agent/drivers/hermes.js +795 -0
- package/dist/agent/goal.js +274 -0
- package/dist/agent/handover.js +130 -0
- package/dist/agent/images.js +355 -0
- package/dist/agent/index.js +50 -0
- package/dist/agent/mcp/bridge.js +791 -0
- package/dist/agent/mcp/extensions.js +637 -0
- package/dist/agent/mcp/oauth.js +353 -0
- package/dist/agent/mcp/registry.js +119 -0
- package/dist/agent/mcp/session-server.js +229 -0
- package/dist/agent/mcp/tools/ask-user.js +113 -0
- package/dist/agent/mcp/tools/await-resume.js +77 -0
- package/dist/agent/mcp/tools/goal.js +144 -0
- package/dist/agent/mcp/tools/types.js +12 -0
- package/dist/agent/mcp/tools/workspace.js +212 -0
- package/dist/agent/npm.js +31 -0
- package/dist/agent/session.js +1206 -0
- package/dist/agent/skill-installer.js +160 -0
- package/dist/agent/skills.js +257 -0
- package/dist/agent/stream.js +743 -0
- package/dist/agent/types.js +13 -0
- package/dist/agent/utils.js +687 -0
- package/dist/bot/bot.js +2499 -0
- package/dist/bot/command-ui.js +633 -0
- package/dist/bot/commands.js +513 -0
- package/dist/bot/headless-bot.js +36 -0
- package/dist/bot/host.js +192 -0
- package/dist/bot/human-loop.js +168 -0
- package/dist/bot/menu.js +48 -0
- package/dist/bot/orchestration.js +79 -0
- package/dist/bot/render-shared.js +309 -0
- package/dist/bot/session-hub.js +361 -0
- package/dist/bot/session-status.js +55 -0
- package/dist/bot/streaming.js +309 -0
- package/dist/browser-profile.js +579 -0
- package/dist/browser-supervisor.js +249 -0
- package/dist/catalog/cli-tools.js +421 -0
- package/dist/catalog/index.js +21 -0
- package/dist/catalog/local-models.js +94 -0
- package/dist/catalog/mcp-servers.js +315 -0
- package/dist/catalog/skill-repos.js +173 -0
- package/dist/channels/base.js +55 -0
- package/dist/channels/dingtalk/bot.js +549 -0
- package/dist/channels/dingtalk/channel.js +268 -0
- package/dist/channels/discord/bot.js +552 -0
- package/dist/channels/discord/channel.js +245 -0
- package/dist/channels/feishu/bot.js +1275 -0
- package/dist/channels/feishu/channel.js +911 -0
- package/dist/channels/feishu/markdown.js +91 -0
- package/dist/channels/feishu/render.js +619 -0
- package/dist/channels/health.js +109 -0
- package/dist/channels/slack/bot.js +554 -0
- package/dist/channels/slack/channel.js +283 -0
- package/dist/channels/states.js +6 -0
- package/dist/channels/telegram/bot.js +1310 -0
- package/dist/channels/telegram/channel.js +820 -0
- package/dist/channels/telegram/directory.js +111 -0
- package/dist/channels/telegram/live-preview.js +220 -0
- package/dist/channels/telegram/render.js +384 -0
- package/dist/channels/wecom/bot.js +558 -0
- package/dist/channels/wecom/channel.js +479 -0
- package/dist/channels/weixin/api.js +520 -0
- package/dist/channels/weixin/bot.js +1000 -0
- package/dist/channels/weixin/channel.js +222 -0
- package/dist/cli/autostart.js +262 -0
- package/dist/cli/channel-supervisor.js +313 -0
- package/dist/cli/channels.js +54 -0
- package/dist/cli/main.js +726 -0
- package/dist/cli/onboarding.js +227 -0
- package/dist/cli/run.js +308 -0
- package/dist/cli/setup-wizard.js +235 -0
- package/dist/core/config/runtime-config.js +201 -0
- package/dist/core/config/user-config.js +510 -0
- package/dist/core/config/validation.js +521 -0
- package/dist/core/constants.js +400 -0
- package/dist/core/git.js +145 -0
- package/dist/core/legacy-compat.js +60 -0
- package/dist/core/logging.js +101 -0
- package/dist/core/platform.js +59 -0
- package/dist/core/process-control.js +315 -0
- package/dist/core/secrets/index.js +42 -0
- package/dist/core/secrets/inline-seal.js +60 -0
- package/dist/core/secrets/ref.js +33 -0
- package/dist/core/secrets/resolver.js +65 -0
- package/dist/core/secrets/store.js +63 -0
- package/dist/core/utils.js +233 -0
- package/dist/core/version.js +15 -0
- package/dist/dashboard/platform.js +219 -0
- package/dist/dashboard/routes/agents.js +450 -0
- package/dist/dashboard/routes/cli.js +174 -0
- package/dist/dashboard/routes/config.js +523 -0
- package/dist/dashboard/routes/extensions.js +745 -0
- package/dist/dashboard/routes/local-models.js +290 -0
- package/dist/dashboard/routes/models.js +324 -0
- package/dist/dashboard/routes/sessions.js +838 -0
- package/dist/dashboard/runtime.js +410 -0
- package/dist/dashboard/server.js +237 -0
- package/dist/dashboard/session-control.js +347 -0
- package/dist/model/catalog.js +104 -0
- package/dist/model/index.js +20 -0
- package/dist/model/injector.js +272 -0
- package/dist/model/provider-models.js +112 -0
- package/dist/model/store.js +212 -0
- package/dist/model/types.js +13 -0
- package/dist/model/validation.js +203 -0
- package/package.json +82 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as t,j as n}from"./react-vendor-C7Sl8SE7.js";import{c as mt,I as gt,S as ke,i as Se,a as T,u as We,d as ht,g as pt,h as xt,s as kt,K as St}from"./index-DXSohzrE.js";import{l as bt,n as Xe,m as vt,a as yt,b as It,p as Tt,u as jt,c as Rt,T as wt,R as Nt,U as Ot,d as Lt,e as Mt,f as Ct,L as Et,I as At}from"./index-CpM4CqZJ.js";import{M as Ge,a as Ye}from"./Modal-CTeL0y7P.js";import"./router-DHISdpPk.js";import"./Select-C8tOdPhe.js";import"./DirBrowser-Ckcmi-Pi.js";import"./markdown-DxQYQFeH.js";import"./ExtensionsTab-KZhEDrdu.js";function Ft({snapshot:i}){const[r,p]=t.useState(i.currentIndex??0),[M,j]=t.useState(""),[x,h]=t.useState(!1),[W,k]=t.useState(null);t.useEffect(()=>{p(i.currentIndex??0),j(""),k(null)},[i.promptId,i.currentIndex]);const C=i.questions||[],b=C[r]||null,X=C.length,w=!!(b?.options&&b.options.length),d=w?!!b?.allowFreeform:!0,H=a=>{a&&(p(m=>m+1),j(""))},ne=async a=>{if(!x){h(!0),k(null);try{const m=await T.interactionSelectOption(i.promptId,a);if(!m.ok){k(m.error||"Failed to submit selection.");return}H(m.advanced)}catch(m){k(m?.message||"Network error.")}finally{h(!1)}}},N=async()=>{if(x)return;const a=M.trim();if(!a&&!b?.allowEmpty){k("Please enter a response.");return}h(!0),k(null);try{const m=await T.interactionSubmitText(i.promptId,a);if(!m.ok){k(m.error||"Failed to submit answer.");return}H(m.advanced)}catch(m){k(m?.message||"Network error.")}finally{h(!1)}},f=async()=>{if(!x){h(!0),k(null);try{const a=await T.interactionSkip(i.promptId);if(!a.ok){k(a.error||"Failed to skip.");return}H(a.advanced)}catch(a){k(a?.message||"Network error.")}finally{h(!1)}}},P=async()=>{if(!x){h(!0);try{await T.interactionCancel(i.promptId)}catch{}}},V=t.useMemo(()=>{const a=[];return i.hint&&a.push(i.hint),X>1&&a.push(`Question ${r+1} of ${X}`),a.join(" · ")||void 0},[i.hint,r,X]);return n.jsxs(Ge,{open:!0,onClose:P,wide:w&&(b?.options?.length||0)>3,children:[n.jsx(Ye,{title:i.title||"Pikiloop needs your input",description:V,onClose:P}),b?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:b.header||"Question"}),n.jsx("div",{className:"mt-1 whitespace-pre-wrap text-sm leading-relaxed text-fg",children:b.prompt})]}),w&&n.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2",children:(b.options||[]).map(a=>n.jsxs("button",{type:"button",disabled:x,onClick:()=>ne(a.value||a.label),className:mt("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:a.label}),a.description&&n.jsx("div",{className:"mt-0.5 text-xs leading-snug text-fg-4",children:a.description})]},a.value||a.label))}),d&&n.jsx("div",{children:n.jsx(gt,{value:M,onChange:a=>j(a.target.value),onKeyDown:a=>{a.key==="Enter"&&!a.shiftKey&&!x&&(a.preventDefault(),N())},placeholder:w?"Or type a custom answer…":"Type your answer…",disabled:x,autoFocus:!w})}),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:f,disabled:x,children:"Skip"}),d&&n.jsx(Se,{variant:"primary",size:"sm",onClick:N,disabled:x||!M.trim()&&!b.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 Fe=12,Ve=160,Ht=96,Pt=20,z=new Map;function qt(i,r){return`${i}:${r}`}function Dt(i,r){for(z.delete(i),z.set(i,r);z.size>Pt;)z.delete(z.keys().next().value)}const Vt=t.memo(function({session:r,workdir:p,active:M=!0,onSessionChange:j,initialPendingPrompt:x,initialPendingImageUrls:h,onPendingPromptConsumed:W}){const k=We(e=>e.locale),C=We(e=>e.agentStatus?.agents?.find(s=>s.agent===r.agent)??null),b=C?.selectedEffort??null,X=C?.selectedModel??null,w=C?.byokProviderName??null,d=t.useMemo(()=>ht(k),[k]),H=pt(r.agent||""),ne=xt(r),N=!!x||!!(h&&h.length),[f,P]=t.useState(null),[V,a]=t.useState(!N),[m,He]=t.useState(!1),[g,q]=t.useState(null),[G,Y]=t.useState(!1),[se,be]=t.useState(null),[Je,Pe]=t.useState(0),[Ze,ve]=t.useState(null),[le,ae]=t.useState([]),[et,oe]=t.useState([]),[J,ye]=t.useState([]),[S,ue]=t.useState(x||null),[O,ce]=t.useState(h||[]),[tt,ie]=t.useState(null),Ie=t.useRef(null);Ie.current=tt;const[qe,D]=t.useState([]),De=t.useRef([]);De.current=qe;const Z=t.useRef(null),[rt,Ue]=t.useState(null),[de,ee]=t.useState(null),[te,Te]=t.useState(""),[E,je]=t.useState(!1),nt=!!C?.capabilities?.fork,Re=t.useRef(null),U=t.useRef(h||[]),L=t.useRef(g),$e=t.useRef(G);L.current=g,$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(N),re=t.useRef(!1),F=t.useRef(!1),Ne=t.useRef(!1),Oe=t.useRef(!1),Be=t.useRef({model:null,effort:null}),st=t.useCallback(e=>{Be.current=e},[]);t.useEffect(()=>{Ne.current||!N||(Ne.current=!0,x&&!S&&ue(x),h&&h.length&&!O.length&&(ce(h),U.current=h),a(!1),Pe(e=>e+1),W?.())},[N,W]);const v=t.useCallback(()=>{ue(null),ce(e=>{for(const s of e)URL.revokeObjectURL(s);return[]}),U.current=[],ie(null)},[]),K=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=!!L.current||$e.current,o=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:o}]);return}for(const u of U.current)URL.revokeObjectURL(u);Z.current=null,ue(e||null),ce(o),U.current=o,ie(null)},[]),lt=t.useCallback(e=>{const s=Z.current;if(s){Z.current=null,D(l=>{const o=l.findIndex(c=>c.localId===s);if(o<0)return l;const u=l.slice();return u[o]={...u[o],taskId:e},u});return}ie(e)},[]),at=t.useCallback(async()=>{if(!de)return;const e=te.trim();if(e){je(!0);try{const s=await T.forkSession(p,r.agent||"",r.sessionId,de.atTurn,e,{});if(!s.ok||!s.sessionKey){je(!1);return}const[l,o]=s.sessionKey.split(":");ee(null),Te(""),j?.({agent:l,sessionId:o,workdir:p})}finally{je(!1)}}},[de,te,p,r.agent,r.sessionId,j]);Re.current=at;const ge=t.useCallback(async(e,s={})=>{try{const l=await bt({workdir:p,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}},[p,r.agent,r.sessionId]),y=t.useCallback(async({keepOlder:e,force:s=!1,scrollToBottom:l=!1})=>{const o=r.sessionId;if(me.current===o)return!1;me.current=o;try{const u=await ge({turnOffset:0,turnLimit:Fe},{force:s});if(!u||r.sessionId!==o)return!1;if(l&&(B.current=!0),P(c=>!c||!e?u:vt(c,u)),a(!1),re.current&&(re.current=!1,v()),F.current){const c=F.current;F.current=!1;const I=c!==!0?c.taskId:null;L.current&&(c===!0||L.current.taskId===I)&&q(null)}return!0}finally{me.current===o&&(me.current=null)}},[ge,v,r.sessionId]),he=t.useCallback(async()=>{if(!f?.hasOlder||we.current)return;const e=A.current;e&&(fe.current={scrollHeight:e.scrollHeight,scrollTop:e.scrollTop}),we.current=!0,He(!0);try{const s=await ge({turnOffset:Math.max(0,f.totalTurns-f.startTurn),turnLimit:Fe});s?P(l=>l?yt(l,s):s):fe.current=null}finally{we.current=!1,He(!1)}},[ge,f]),pe=t.useRef(null),_=t.useCallback(e=>{if(e?.sessionId&&e.sessionId!==r.sessionId&&(Oe.current=!0,Le.current=`${r.agent}:${e.sessionId}`,j?.({agent:r.agent||"",sessionId:e.sessionId,workdir:p})),!e){const l=pe.current;Y(!1),l==="streaming"?(re.current=!0,F.current=!0,y({keepOlder:!0,force:!0,scrollToBottom:$.current})):q(null),l==="done"?(v(),K()):l===null&&Q.current&&y({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(F.current&&L.current&&L.current.taskId!==null&&L.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,startedAt:typeof e.startedAt=="number"?e.startedAt:null,error:null}),Y(!0),e.taskId&&e.taskId!==Ie.current){const o=De.current,u=o.findIndex(c=>c.taskId===e.taskId);if(u>=0){const c=o[u];for(const I of U.current)URL.revokeObjectURL(I);ue(c.prompt||null),ce(c.imageUrls),U.current=c.imageUrls,ie(e.taskId),D(I=>I.filter((dt,ft)=>ft!==u))}}$.current&&(B.current=!0)}else if(e.phase==="queued")q(null),Y(!1);else if(e.phase==="done"){Y(!1),q(I=>I?{...I,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,error:e.error}:I);const l=!!e.queuedTaskIds?.length,o=L.current,u=!!o&&It(o),c=!!e.incomplete&&u&&!l;pe.current!=="done"&&(l||(re.current=!0),F.current=c?!1:{taskId:e.taskId||null},y({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 o=!1;const u=[];for(const c of l)if(!c.taskId||s.has(c.taskId))u.push(c);else{for(const I of c.imageUrls)URL.revokeObjectURL(I);o=!0}return o?u:l}),pe.current=e.phase},[v,K,y,r.sessionId,r.agent,j,p]),Ke=t.useCallback(()=>{Q.current=!0,Pe(e=>e+1)},[]),ot=t.useCallback(async e=>{try{await T.recallSessionMessage(e),Ie.current===e&&v(),D(s=>{let l=!1;const o=[];for(const u of s)if(u.taskId===e){for(const c of u.imageUrls)URL.revokeObjectURL(c);l=!0}else o.push(u);return l?o:s}),ae(s=>s.filter(l=>l!==e)),oe(s=>s.filter(l=>l.taskId!==e)),ve(s=>s===e?null:s)}catch{}},[v]),ut=t.useCallback(async e=>{try{await T.steerSession(e)}catch{}},[]),ct=t.useCallback(async()=>{try{await T.stopSession(r.agent||"",r.sessionId)}catch{}},[r.agent,r.sessionId]),xe=qt(r.agent||"",r.sessionId);t.useEffect(()=>{if(Oe.current){Oe.current=!1;let u=!1;return y({keepOlder:!0,force:!0}).finally(()=>{u||a(!1)}),()=>{u=!0}}let e=!1;const s=Tt({workdir:p,agent:r.agent||"",sessionId:r.sessionId,rich:!0,turnOffset:0,turnLimit:Fe},{allowStale:!0}),l=N&&!Ne.current,o=s?.ok?Xe(s):z.get(xe)||null;return a(l?!1:!o),P(o),q(null),Y(!1),be(null),ae([]),oe([]),ye([]),l||(v(),K(),Q.current=!1,re.current=!1,F.current=!1),$.current=!0,B.current=!0,l||y({keepOlder:!1,force:!0}).finally(()=>{e||a(!1)}),()=>{e=!0}},[y,r.agent,r.sessionId,p,xe,v,K]),t.useEffect(()=>{f&&f.turns.length>0&&Dt(xe,f)},[xe,f]),t.useEffect(()=>{M&&y({keepOlder:!0,force:!0})},[M,y]);const Le=t.useRef(`${r.agent}:${r.sessionId}`);Le.current=`${r.agent}:${r.sessionId}`,jt("stream-update",t.useCallback(e=>{e.key===Le.current&&_(e.snapshot??null)},[_])),t.useEffect(()=>{let e=!0;return T.getSessionStreamState(r.agent||"",r.sessionId).then(s=>{e&&_(s.state)}).catch(()=>{}),()=>{e=!1}},[_,r.agent,r.sessionId,Je]),Rt(t.useCallback(()=>{T.getSessionStreamState(r.agent||"",r.sessionId).then(e=>{_(e.state)}).catch(()=>{}),y({keepOlder:!0,force:!0})},[_,r.agent,r.sessionId,y])),t.useEffect(()=>{!Q.current&&ne!=="running"&&!G&&!g&&!se&&le.length===0&&(v(),K())},[ne,G,g,se,le.length,v,K]),t.useLayoutEffect(()=>{const e=fe.current,s=A.current;!e||!s||(fe.current=null,s.scrollTop=e.scrollTop+(s.scrollHeight-e.scrollHeight))},[f?.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)}))},[f,g]),t.useLayoutEffect(()=>{if(!S)return;const e=A.current;e&&(e.scrollTop=e.scrollHeight)},[S]),t.useEffect(()=>{if(!f?.hasOlder||V||m)return;const e=A.current;e&&e.scrollHeight<=e.clientHeight+Ve&&he()},[f?.hasOlder,f?.turns.length,he,V,m]);const it=t.useCallback(()=>{const e=A.current;if(!e)return;const s=e.scrollHeight-e.scrollTop-e.clientHeight;$.current=s<=Ht,e.scrollTop<=Ve&&he()},[he]),Me=g?.model||r.model||X||null,Ce=g?.effort||r.thinkingEffort||b||null,_e=Me?kt(Me):null,Ee=St(r,{streaming:G,hasLiveStream:!!g,streamPhase:se,queuedTaskCount:le.length}),R=f?.turns||[],Ae=t.useMemo(()=>{if(!O.length||!R.length)return!1;const e=R[R.length-1];return!e.user||(e.user.text?.trim()||"")!==(S||"").trim()?!1:e.user.blocks.filter(l=>l.type==="image").length<O.length},[R,S,O.length]),ze=t.useMemo(()=>{let e=R;if(Ae){const l=e[e.length-1];e=[...e.slice(0,-1),{...l,user:null}]}if(!g||!e.length)return e;const s=e[e.length-1];return!s.assistant||S&&s.user?.text?.trim()!==S.trim()?e:[...e.slice(0,-1),{...s,assistant:null}]},[R,g,S,Ae]);return n.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[n.jsx("div",{ref:A,onScroll:it,className:"flex-1 overflow-y-auto overscroll-contain",children:V&&!S&&!O.length&&!g?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&&!O.length&&!g&&!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:[(f?.hasOlder||m)&&n.jsxs("div",{className:"mb-4 flex items-center justify-center gap-2 text-[11px] text-fg-5",children:[m?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(m?"hub.loadingOlderTurns":"hub.loadOlderTurnsHint")})]}),r.migratedFrom?.kind==="fork"&&r.migratedFrom.sessionId&&n.jsxs("button",{type:"button",onClick:()=>j?.({agent:r.migratedFrom.agent||r.agent||"",sessionId:r.migratedFrom.sessionId,workdir:p}),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=(f?.startTurn||0)+s;return n.jsx(wt,{turn:e,turnIndex:l,agent:r.agent||"",meta:H,model:_e,effort:Ce,providerName:w,t:d,onResend:o=>{B.current=!0,Qe(o);const u=Be.current;T.sendSessionMessage(p,r.agent||"",r.sessionId,o,{model:u.model||Me||void 0,effort:u.effort||Ce||void 0}).then(c=>{c.ok&&Ke()}).catch(()=>{v()})},onEdit:o=>Ue(o),onFork:nt?o=>{Te(""),ee({atTurn:o})}:void 0},`${f?.startTurn||0}:${s}`)}),Ee&&n.jsx("div",{className:"mb-5 animate-in",children:n.jsx(Nt,{detail:Ee,t:d})}),(S||O.length>0)&&(Ae||!(S&&R.length>0&&R[R.length-1]?.user?.text?.trim()===S.trim()))&&n.jsxs("div",{className:"session-turn",children:[n.jsx(Ot,{text:S||"",blocks:O.map(e=>({type:"image",content:e})),t:d}),!g&&n.jsx("div",{className:"mt-3 mb-5 animate-in",children:n.jsx(Lt,{className:"text-fg-5"})})]}),g&&Mt(g)&&n.jsxs("div",{className:"mb-6",children:[n.jsx(Ct,{agent:r.agent||"",meta:H,model:_e,effort:Ce,providerName:w,previewMeta:g.previewMeta,liveStartedAt:g.phase==="streaming"?g.startedAt??null:null}),n.jsx(Et,{stream:g,t:d})]}),n.jsx("div",{className:"h-4"})]})}),n.jsx(At,{session:r,workdir:p,onStreamQueued:Ke,onSendStart:Qe,onSendTaskAssigned:lt,onSessionChange:j,t:d,streamPhase:se,streamTaskId:Ze,queuedTaskIds:le,queuedTasks:et,pendingQueuedSends:qe,onRecall:ot,onSteer:ut,onStopAll:ct,editDraft:rt,onEditDraftConsumed:()=>Ue(null),onSelectionChange:st}),de&&n.jsxs(Ge,{open:!0,onClose:()=>{E||ee(null)},children:[n.jsx(Ye,{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")})]})]}),M&&J.length>0&&n.jsx(Ft,{snapshot:J[J.length-1]},J[J.length-1].promptId)]})});export{Vt as SessionPanel};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e,r as f}from"./react-vendor-C7Sl8SE7.js";import{G as v,c as C,H as G,u as x,d as F,a as $,i as w,R as L,v as g,x as O}from"./index-DXSohzrE.js";import{S as N}from"./shared-BIP_4k4I.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:`${G(i)} / ${G(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(v,{className:"h-3 w-12"}),e.jsx(v,{className:"h-3 w-24"}),e.jsx(v,{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(()=>F(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(()=>F(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(N,{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(N,{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?`Pikiloop v${r.version}`:"Pikiloop",r?.nodeVersion?` · Node ${r.nodeVersion}`:""]})]}),e.jsx(q,{items:E(o,t),loading:!o})]}),e.jsxs(N,{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};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" id="Layer_1" viewBox="0 0 192 192"><defs><clipPath id="clippath"><path d="M164.93 86.68c-13.56-5.84-25.42-13.84-35.6-24.01-10.17-10.17-18.18-22.04-24.01-35.6-2.23-5.19-4.04-10.54-5.42-16.02C99.45 9.26 97.85 8 96 8s-3.45 1.26-3.9 3.05c-1.38 5.48-3.18 10.81-5.42 16.02-5.84 13.56-13.84 25.43-24.01 35.6-10.17 10.16-22.04 18.17-35.6 24.01-5.19 2.23-10.54 4.04-16.02 5.42C9.26 92.55 8 94.15 8 96s1.26 3.45 3.05 3.9c5.48 1.38 10.81 3.18 16.02 5.42 13.56 5.84 25.42 13.84 35.6 24.01 10.17 10.17 18.18 22.04 24.01 35.6 2.24 5.2 4.04 10.54 5.42 16.02A4.03 4.03 0 0 0 96 184c1.85 0 3.45-1.26 3.9-3.05 1.38-5.48 3.18-10.81 5.42-16.02 5.84-13.56 13.84-25.42 24.01-35.6 10.17-10.17 22.04-18.18 35.6-24.01 5.2-2.24 10.54-4.04 16.02-5.42A4.03 4.03 0 0 0 184 96c0-1.85-1.26-3.45-3.05-3.9-5.48-1.38-10.81-3.18-16.02-5.42" class="st0"/></clipPath><clipPath id="clippath-1"><path d="M164.93 86.68c-13.56-5.84-25.42-13.84-35.6-24.01-10.17-10.17-18.18-22.04-24.01-35.6-2.23-5.19-4.04-10.54-5.42-16.02C99.45 9.26 97.85 8 96 8s-3.45 1.26-3.9 3.05c-1.38 5.48-3.18 10.81-5.42 16.02-5.84 13.56-13.84 25.43-24.01 35.6-10.17 10.16-22.04 18.17-35.6 24.01-5.19 2.23-10.54 4.04-16.02 5.42C9.26 92.55 8 94.15 8 96s1.26 3.45 3.05 3.9c5.48 1.38 10.81 3.18 16.02 5.42 13.56 5.84 25.42 13.84 35.6 24.01 10.17 10.17 18.18 22.04 24.01 35.6 2.24 5.2 4.04 10.54 5.42 16.02A4.03 4.03 0 0 0 96 184c1.85 0 3.45-1.26 3.9-3.05 1.38-5.48 3.18-10.81 5.42-16.02 5.84-13.56 13.84-25.42 24.01-35.6 10.17-10.17 22.04-18.18 35.6-24.01 5.2-2.24 10.54-4.04 16.02-5.42A4.03 4.03 0 0 0 184 96c0-1.85-1.26-3.45-3.05-3.9-5.48-1.38-10.81-3.18-16.02-5.42" class="st0"/></clipPath><radialGradient id="radial-gradient" cx="-122.49" cy="-223.53" r="110.98" fx="-122.49" fy="-223.53" gradientTransform="matrix(1 0 0 -.54 0 -.93)" gradientUnits="userSpaceOnUse"><stop offset=".31" stop-color="#3186ff"/><stop offset=".42" stop-color="#4491ff"/><stop offset=".45" stop-color="#4c96ff"/><stop offset=".81" stop-color="#e7f1ff"/><stop offset=".89" stop-color="#fff"/></radialGradient><style>.st0{fill:none}</style></defs><g style="clip-path:url(#clippath)"><image xlink:href="data:image/jpeg;base64,/9j/4S5+aHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wLwA8P3hwYWNrZXQgYmVnaW49Iu+7vyIgaWQ9Ilc1TTBNcENlaGlIenJlU3pOVGN6a2M5ZCI/Pgo8eDp4bXBtZXRhIHhtbG5zOng9ImFkb2JlOm5zOm1ldGEvIiB4OnhtcHRrPSJBZG9iZSBYTVAgQ29yZSA5LjEtYzAwMyAxLjAwMDAwMCwgMDAwMC8wMC8wMC0wMDowMDowMCAgICAgICAgIj4KICAgPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4KICAgICAgPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIKICAgICAgICAgICAgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAv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BtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgIC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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAH//05mAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB//9k=" width="472" height="461" transform="translate(-187.2 -95.81)"/><g style="clip-path:url(#clippath-1)"><path d="M-321.98 8h221.96v221.96h-221.96z" style="fill:url(#radial-gradient)"/></g><path d="M164.93 86.68c-13.56-5.84-25.42-13.84-35.6-24.01-10.17-10.17-18.18-22.04-24.01-35.6-2.23-5.19-4.04-10.54-5.42-16.02C99.45 9.26 97.85 8 96 8s-3.45 1.26-3.9 3.05c-1.38 5.48-3.18 10.81-5.42 16.02-5.84 13.56-13.84 25.43-24.01 35.6-10.17 10.16-22.04 18.17-35.6 24.01-5.19 2.23-10.54 4.04-16.02 5.42C9.26 92.55 8 94.15 8 96s1.26 3.45 3.05 3.9c5.48 1.38 10.81 3.18 16.02 5.42 13.56 5.84 25.42 13.84 35.6 24.01 10.17 10.17 18.18 22.04 24.01 35.6 2.24 5.2 4.04 10.54 5.42 16.02A4.03 4.03 0 0 0 96 184c1.85 0 3.45-1.26 3.9-3.05 1.38-5.48 3.18-10.81 5.42-16.02 5.84-13.56 13.84-25.42 24.01-35.6 10.17-10.17 22.04-18.18 35.6-24.01 5.2-2.24 10.54-4.04 16.02-5.42A4.03 4.03 0 0 0 184 96c0-1.85-1.26-3.45-3.05-3.9-5.48-1.38-10.81-3.18-16.02-5.42" class="st0"/></g></svg>
|
|
Binary file
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionPanel-C1geSRxw.js","assets/react-vendor-C7Sl8SE7.js","assets/index-DXSohzrE.js","assets/router-DHISdpPk.js","assets/index-reSbuley.css","assets/Modal-CTeL0y7P.js","assets/Select-C8tOdPhe.js","assets/DirBrowser-Ckcmi-Pi.js","assets/markdown-DxQYQFeH.js","assets/ExtensionsTab-KZhEDrdu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{c as L,a as J,u as je,A as rs,s as sn,S as he,B as Xe,g as Yt,w as os,b as is,E as Vt,C as rn,d as as,e as ls,n as cs,f as yn,h as It,i as Ee,D as Wt,j as ds,k as Nn,_ as Sn,T as us,l as hs}from"./index-DXSohzrE.js";import{j as e,r,a as on}from"./react-vendor-C7Sl8SE7.js";import{I as ps}from"./Select-C8tOdPhe.js";import{M as _t,a as Pt}from"./Modal-CTeL0y7P.js";import{D as xs}from"./DirBrowser-Ckcmi-Pi.js";import{n as fs,r as gs,M as an}from"./markdown-DxQYQFeH.js";import{WorkspaceExtensionsBody as ms}from"./ExtensionsTab-KZhEDrdu.js";function bs({open:t,className:n}){return e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:L("shrink-0 text-fg-5/40 transition-transform duration-200",t&&"rotate-180",n),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Ze({open:t,onToggle:n,dot:s,label:a,preview:l,badge:d,collapsedContent:p,children:c,className:m}){return e.jsxs("div",{className:L("rounded-md border border-edge bg-panel overflow-hidden","shadow-[0_2px_8px_rgba(0,0,0,0.06)]",m),children:[e.jsxs("button",{onClick:n,className:"w-full flex items-center gap-2.5 px-3.5 py-2.5 text-left hover:bg-panel-h/40 transition-colors",children:[s&&e.jsx("span",{className:L("h-[7px] w-[7px] shrink-0 rounded-full",s.color,s.pulse&&"animate-pulse")}),e.jsx("span",{className:"text-[10.5px] font-semibold uppercase tracking-[0.14em] text-fg-5",children:a}),e.jsx("span",{className:"flex-1 min-w-0 overflow-hidden",children:l}),d,e.jsx(bs,{open:t})]}),!t&&p,t&&c&&e.jsx("div",{className:"border-t border-edge",children:c})]})}const vs=5e3,js=15e3,At=8,Rt=30,ws=1,Je=new Map,ve=new Map,Gt=new Set,Cn=[];let Lt=0;function qt(t){return typeof t=="number"&&Number.isFinite(t)}function Oe(t,n,s,a){for(t.delete(n),t.set(n,s);t.size>a;){const l=t.keys().next().value;if(!l)break;t.delete(l)}}function En(t,n){const s=t.get(n);return!s?.value||s.expiresAt<=Date.now()?null:(Oe(t,n,s,t===ve?Rt:At),s.value)}function Ln(t){return{workdir:t.workdir,agent:t.agent,sessionId:t.sessionId,rich:t.rich??!0,lastNTurns:qt(t.lastNTurns)?t.lastNTurns:void 0,turnOffset:qt(t.turnOffset)?t.turnOffset:void 0,turnLimit:qt(t.turnLimit)?t.turnLimit:void 0}}function ln(t){const n=Ln(t);return[n.workdir,n.agent,n.sessionId,n.rich?"rich":"plain",n.lastNTurns??"",n.turnOffset??"",n.turnLimit??""].join("::")}function Mn(){for(;Lt<ws;){const t=Cn.shift();if(!t)return;Lt+=1,t().finally(()=>{Lt=Math.max(0,Lt-1),Mn()})}}async function ks(t,n={}){const s=t;if(!n.force){const d=En(Je,s);if(d)return d}const a=Je.get(s);if(a?.promise)return a.promise;const l=J.getWorkspaceSessions(t,n.request).then(d=>(Oe(Je,s,{value:d,expiresAt:d.ok?Date.now()+vs:0},At),d)).finally(()=>{const d=Je.get(s);d?.promise&&Oe(Je,s,{value:d.value,expiresAt:d.expiresAt},At)});return Oe(Je,s,{value:a?.value,expiresAt:a?.expiresAt??0,promise:l},At),l}function ys(t,n={}){const s=ln(t),a=ve.get(s);return a?.value?.ok&&(n.allowStale||a.expiresAt>Date.now())?a.value:null}async function Ns(t,n={}){const s=Ln(t),a=ln(s);if(!n.force){const p=En(ve,a);if(p?.ok)return p}const l=ve.get(a);if(l?.promise)return l.promise;const d=J.getSessionMessages(s.workdir,s.agent,s.sessionId,{rich:s.rich,lastNTurns:s.lastNTurns,turnOffset:s.turnOffset,turnLimit:s.turnLimit},n.request).then(p=>(Oe(ve,a,{value:p,expiresAt:p.ok?Date.now()+js:0},Rt),p)).finally(()=>{const p=ve.get(a);p?.promise&&Oe(ve,a,{value:p.value,expiresAt:p.expiresAt},Rt)});return Oe(ve,a,{value:l?.value,expiresAt:l?.expiresAt??0,promise:d},Rt),d}function Ss(t){const n=ln(t);ys(t)||Gt.has(n)||ve.get(n)?.promise||(Gt.add(n),Cn.push(async()=>{try{await Ns(t)}catch{}finally{Gt.delete(n)}}),Mn())}const mt=new Map,Zt=new Set;let De=null,Le=0,gn=!1,Ye=null,gt=500;const Cs=8e3;function Es(t){const n=mt.get(t.type);if(n)for(const s of n)s(t)}function Ls(){const t=window.location;return`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}/ws`}function cn(){if(De)return;Tn();const t=new WebSocket(Ls());t.onopen=()=>{const n=gn;if(gn=!0,gt=500,n)for(const s of Zt)s()},t.onmessage=n=>{try{const s=JSON.parse(n.data);if(s.type==="pong")return;Es(s)}catch{}},t.onclose=()=>{De=null,Le>0&&Ts()},t.onerror=()=>{},De=t}function Ms(){Tn(),De&&(De.close(),De=null)}function Tn(){Ye&&(clearTimeout(Ye),Ye=null)}function Ts(){Ye||(Ye=setTimeout(()=>{Ye=null,Le>0&&cn()},gt),gt=Math.min(gt*2,Cs))}function Is(t,n){let s=mt.get(t);s||(s=new Set,mt.set(t,s)),s.add(n),Le++,Le===1&&cn()}function As(t,n){const s=mt.get(t);s&&(s.delete(n),s.size===0&&mt.delete(t)),Le=Math.max(0,Le-1),Le===0&&Ms()}typeof document<"u"&&document.addEventListener("visibilitychange",()=>{document.visibilityState==="visible"&&Le>0&&!De&&(gt=500,cn())});function mn(t,n){const s=r.useRef(n);s.current=n,r.useEffect(()=>{if(!t)return;const a=l=>s.current(l);return Is(t,a),()=>As(t,a)},[t])}function Rs(t){const n=r.useRef(t);n.current=t,r.useEffect(()=>{const s=()=>n.current();return Zt.add(s),()=>{Zt.delete(s)}},[])}function Qr(t){const n=t.richMessages?.length?t.richMessages:t.messages?.map(p=>({role:p.role,text:p.text,blocks:[{type:"text",content:p.text}]}))||[],s=Ps(n),a=Math.max(t.window?.totalTurns??t.totalTurns??s.length,s.length),l=t.window?.endTurn??a,d=t.window?.startTurn??Math.max(0,l-s.length);return{turns:s,startTurn:d,endTurn:l,totalTurns:a,hasOlder:t.window?.hasOlder??d>0}}function Jr(t,n){const s=Math.max(0,t.startTurn-n.startTurn);return{turns:[...n.turns.slice(0,s),...t.turns],startTurn:n.startTurn,endTurn:t.endTurn,totalTurns:Math.max(t.totalTurns,n.totalTurns),hasOlder:n.hasOlder}}function Xr(t,n){if(n.startTurn<=t.startTurn)return n;const s=Math.max(0,n.startTurn-t.startTurn);return{turns:[...t.turns.slice(0,s),...n.turns],startTurn:t.startTurn,endTurn:n.endTurn,totalTurns:n.totalTurns,hasOlder:t.startTurn>0}}function _s(t,n){const s=[t.text,n.text].filter(Boolean);return{role:t.role,text:s.join(`
|
|
3
|
+
|
|
4
|
+
`),blocks:[...t.blocks,...n.blocks],usage:n.usage??t.usage??null}}function Ps(t){const n=[];let s={user:null,assistant:null};for(const a of t)if(a.role==="user"){if(s.assistant&&In(a.text))continue;(s.user||s.assistant)&&(n.push(s),s={user:null,assistant:null}),s.user=a}else s.assistant?s.assistant=_s(s.assistant,a):s.assistant=a;return(s.user||s.assistant)&&n.push(s),n}const Ws=new Set(["task-notification","system-reminder","persisted-output","local-command-stdout","local-command-caveat","local-command-stderr","ide_opened_file","ide_diagnostics","ide_selection","event","analysis","case_id","tool-use-id","output-file"]),Bs=["continued from a previous","summary below covers","earlier portion of the conversation","Summary:","Key Technical Concepts"];function In(t){const s=t.trim().match(/^<([a-z][a-z0-9_-]*)\b/i);return s&&Ws.has(s[1].toLowerCase())?!0:Bs.some(a=>t.includes(a))}function An(t,n){const s=t.split(`
|
|
5
|
+
`).filter(a=>a.trim());return s.length<=n?s.join(`
|
|
6
|
+
`):s.slice(-n).join(`
|
|
7
|
+
`)}function $s(t){const n=String(t||"").trim().toLowerCase();return n?n.startsWith("interrupted by user")?"interrupted":n.startsWith("timed out")||n.startsWith("stopped before completion")||n.includes("max tokens")?"incomplete":"error":"error"}function Qt(t){return{id:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,file:t,previewUrl:URL.createObjectURL(t)}}function Os(t){for(const n of t)URL.revokeObjectURL(n.previewUrl)}function Ds(t){if(!Number.isFinite(t)||t<=0)return"0 B";if(t<1024)return`${t} B`;const n=t/1024;if(n<1024)return`${n.toFixed(n>=100?0:1)} KB`;const s=n/1024;return`${s.toFixed(s>=100?0:1)} MB`}async function Fs(t){if(typeof ClipboardItem>"u"||!navigator.clipboard?.write)return!1;try{return await navigator.clipboard.write([new ClipboardItem({[t.type||"image/png"]:t})]),!0}catch{return!1}}function Q(t,n=120){if(t==null)return"";const a=(typeof t=="string"?t:String(t)).replace(/\s+/g," ").trim();return a.length<=n?a:a.slice(0,Math.max(0,n-1))+"…"}function Us(t){if(!t)return null;try{const n=JSON.parse(t);return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Rn(t){const n=String(t.toolName||"").trim()||"Tool",s=Us(t.content);if(!s)return n;const a=Q(s.description,120);switch(n){case"Read":{const l=Q(s.file_path||s.path,140);return l?`Read ${l}`:"Read"}case"Edit":{const l=Q(s.file_path||s.path,140);return l?`Edit ${l}`:"Edit"}case"Write":{const l=Q(s.file_path||s.path,140);return l?`Write ${l}`:"Write"}case"Glob":{const l=Q(s.pattern||s.glob,120);return l?`Glob ${l}`:"Glob"}case"Grep":{const l=Q(s.pattern||s.query,120);return l?`Grep ${l}`:"Grep"}case"WebFetch":{const l=Q(s.url,120);return l?`WebFetch ${l}`:"WebFetch"}case"WebSearch":{const l=Q(s.query,120);return l?`WebSearch ${l}`:"WebSearch"}case"TodoWrite":return"Update plan";case"AskUserQuestion":{const d=(Array.isArray(s.questions)?s.questions:[])[0],p=Q(d?.question||s.question,120);return p?`Ask user: ${p}`:"Ask user"}case"Task":{const l=Q(s.description||s.prompt,120);return l?`Task: ${l}`:"Task"}case"Bash":{if(a)return`Bash: ${a}`;const l=Q(s.command,120);return l?`Bash: ${l}`:"Bash"}default:{const l=n.match(/^mcp__[^_]+__(.+)$/),d=l?l[1]:n;if(d==="im_send_file"){const c=Q(s.path,120);return c?`Send file: ${c}`:"Send file"}if(d==="im_list_files")return"List workspace files";if(a)return`${n}: ${a}`;const p=Q(s.file_path||s.path||s.command||s.query||s.pattern||s.url,120);return p?`${n}: ${p}`:n}}}function zs(t){const n=(t.content||"").trim();if(!n)return"result";const s=n.split(`
|
|
8
|
+
`).map(a=>a.trim()).find(Boolean)||"";return s?Q(s,140):"result"}function Hs(t){const n=t.indexOf(":");if(n<=0)return null;const s=t.slice(0,n).trim(),a=t.slice(n+1).trim();return!s||!a?null:{agent:s,sessionId:a}}const ft=new Map;function Ks(t,n){return`${t}:${n}`}function Vs(t){const n=(()=>{try{return new URL(t.baseURL).host.toLowerCase()}catch{return""}})();return n.includes("openrouter")?"openrouter":n.includes("anthropic")?"anthropic":n.includes("deepseek")?"deepseek":n.includes("googleapis")||n.includes("vertex")?"google":n.includes("openai.com")?"openai":n.includes("dashscope")||n.includes("qwen")||n.includes("aliyun")?"qwen":n.includes("volces")||n.includes("volcengine")||n.includes("doubao")?"doubao":n.includes("bigmodel")||n.includes("zhipu")||n.includes("z.ai")?"glm":n.includes("minimax")?"minimax":t.kind==="anthropic"?"anthropic":t.kind==="google"?"google":t.kind==="openai"?"openai":"custom"}const Gs=r.memo(function({session:n,workdir:s,onStreamQueued:a,onSendStart:l,onSendTaskAssigned:d,onSessionChange:p,t:c,streamPhase:m,streamTaskId:v,queuedTaskIds:g,queuedTasks:j,pendingQueuedSends:E,onRecall:k,onSteer:N,onStopAll:M,editDraft:A,onEditDraftConsumed:B,onSelectionChange:O}){const[H,_]=r.useState(""),[I,D]=r.useState(!1),[K,ae]=r.useState(null),[Z,T]=r.useState(()=>new Set),[V,Me]=r.useState(()=>new Set),ce=r.useRef({prompt:"",files:[]}),we=je(i=>i.agentStatus?.agents??null),[$,Fe]=r.useState(we||[]),[Te,tt]=r.useState(""),[ke,bt]=r.useState(""),[de,vt]=r.useState(""),[ee,te]=r.useState([]),[Ue,Ie]=r.useState(null),[ze,nt]=r.useState(null),[ne,le]=r.useState(null),[P,ye]=r.useState(null),[X,Ae]=r.useState(null),[Re,jt]=r.useState(void 0),[W,se]=r.useState("closed"),[pe,Ne]=r.useState(null),re=r.useRef(null),_e=r.useRef(!1),st=r.useRef(null),wt=r.useRef(null),He=r.useRef(null),rt=r.useRef([]),[ot,Se]=r.useState([]),[G,xe]=r.useState(!1),[Ce,oe]=r.useState(0),Pe=r.useRef(null),We=je(i=>i.refreshAgentStatus),[ue,it]=r.useState([]),[at,Bt]=r.useState([]),[kt,$t]=r.useState({}),lt=r.useCallback(async()=>{try{const[i,x,b]=await Promise.all([fetch("/api/models/providers").then(S=>S.json()),fetch("/api/models/profiles").then(S=>S.json()),fetch("/api/models/agents").then(S=>S.json())]);if(i?.ok&&Bt(i.providers||[]),x?.ok&&it(x.profiles||[]),b?.ok){const S={};for(const R of b.bindings||[])S[R.agent]=R.activeProfileId;$t(S)}}catch{}},[]);r.useEffect(()=>{we?.length&&Fe(we)},[we]),r.useEffect(()=>{rt.current=ee},[ee]);const Be=Ks(n.agent||"",n.sessionId),Ke=r.useRef(Be);Ke.current=Be,r.useEffect(()=>{const i=ft.get(Be);return i&&(ft.delete(Be),i.text&&_(i.text),i.files.length&&te(i.files.map(Qt))),()=>{const x=re.current?.value||"",b=rt.current.map(S=>S.file);for(const S of rt.current)URL.revokeObjectURL(S.previewUrl);x||b.length?ft.set(Ke.current,{text:x,files:b}):ft.delete(Ke.current)}},[Be]),r.useEffect(()=>{tt(""),bt(""),vt(""),le(null),ye(null),Ae(null),se("closed")},[n.agent,n.sessionId]),r.useEffect(()=>{A!=null&&(_(A),B?.(),requestAnimationFrame(()=>{const i=re.current;i&&(i.focus(),i.setSelectionRange(A.length,A.length))}))},[A,B]),r.useEffect(()=>{if(!s)return;let i=!1;return J.getSkills(s).then(x=>{!i&&x.ok&&Se(x.skills)}).catch(()=>{}),()=>{i=!0}},[s]);const Ve=G?(()=>{const i=H.match(/^\/(\S*)$/);return i?i[1].toLowerCase():null})():null,fe=Ve!==null?ot.filter(i=>i.name.toLowerCase().includes(Ve)||i.label&&i.label.toLowerCase().includes(Ve)):[];r.useEffect(()=>{oe(0)},[G,H]),r.useEffect(()=>{if(!G||!Pe.current)return;const i=Pe.current.querySelector(`[data-skill-idx="${Ce}"]`);i&&i.scrollIntoView({block:"nearest"})},[Ce,G]),r.useEffect(()=>{if(!G)return;const i=x=>{Pe.current?.contains(x.target)||re.current?.contains(x.target)||xe(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[G]),r.useEffect(()=>{if(W==="closed")return;const i=x=>{const b=x.target;He.current?.contains(b)||document.getElementById("cascade-portal")?.contains(b)||(se("closed"),le(null),ye(null),Ae(null))};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[W]),r.useLayoutEffect(()=>{if(W==="closed"||!He.current){Ne(null);return}const i=He.current.getBoundingClientRect();Ne({left:i.left,bottom:window.innerHeight-i.top+8})},[W]);const yt=g&&g.length?g[0]:null;r.useEffect(()=>{K&&(yt||m!==null&&m!=="queued")&&ae(null)},[m,K,yt]),r.useEffect(()=>{const i=re.current;i&&(i.style.height="auto",i.style.height=Math.min(i.scrollHeight,200)+"px")},[H]);const ct=r.useCallback(i=>{const x=Array.from(i||[]).filter(b=>b.type.startsWith("image/"));x.length&&te(b=>[...b,...x.map(Qt)])},[]),Nt=r.useCallback(()=>{Ie(null),te(i=>(Os(i),[]))},[]),St=r.useCallback(i=>{te(x=>{const b=x.find(S=>S.id===i);return b&&URL.revokeObjectURL(b.previewUrl),x.filter(S=>S.id!==i)}),Ie(x=>x===i?null:x)},[]),o=r.useCallback(()=>{const i=H.trim(),x=ee.map(q=>q.file);if(!i&&x.length===0||I)return;const b=Te||n.agent||$.find(q=>q.isDefault)?.agent||"";if(!b)return;const S=$.find(q=>q.agent===b)||null,R=!!n.agent&&b===n.agent,me=(ke||R&&n.model||""||S?.selectedModel||"").trim()||null,be=b==="gemini"?null:(de||R&&n.thinkingEffort||""||S?.selectedEffort||"").trim()||null,Y=b!==n.agent,Kt=Y?"":n.sessionId,ts=Y&&n.agent?n.agent:null,ns=Y&&n.sessionId?n.sessionId:null;D(!0),ce.current={prompt:i,files:x},_(""),ft.delete(Ke.current);const ss=x.length?x.map(q=>URL.createObjectURL(q)):void 0;Nt(),l(i,ss),a(),J.sendSessionMessage(s,b,Kt,i,{attachments:x,model:me,effort:be,previousAgent:ts,previousSessionId:ns}).then(q=>{if(q.taskId&&(ae(q.taskId),d?.(q.taskId)),!q.ok)return;const xt=typeof q.sessionKey=="string"?Hs(q.sessionKey):null;xt&&(xt.agent!==n.agent||xt.sessionId!==n.sessionId)&&xt&&p?.({...xt,workdir:s})}).catch(()=>{}).finally(()=>D(!1))},[$,Nt,ee,H,l,d,p,a,Te,de,ke,I,n.agent,n.sessionId,s]),u=m==="streaming",h=(()=>{const i=[];return g&&g.length&&i.push(...g),m==="queued"&&v&&!i.includes(v)&&i.unshift(v),K&&!i.includes(K)&&(m==="queued"||!m)&&i.push(K),i})(),f=h[h.length-1]||null,w=h.length>0,y=w||u;r.useEffect(()=>{const i=x=>h.includes(x)||x===v;T(x=>{let b=!1;const S=new Set;for(const R of x)i(R)?S.add(R):b=!0;return b?S:x}),Me(x=>{let b=!1;const S=new Set;for(const R of x)i(R)?S.add(R):b=!0;return b?S:x})},[h,v]),r.useEffect(()=>{!w&&ce.current.files.length&&(ce.current={prompt:"",files:[]})},[w]);const C=r.useCallback(i=>{if(!Z.has(i)){if(T(x=>{const b=new Set(x);return b.add(i),b}),i===f){const x=ce.current;x.prompt&&_(x.prompt),x.files.length&&te(x.files.map(Qt)),ce.current={prompt:"",files:[]}}k?.(i),i===K&&ae(null)}},[Z,f,K,k]),[U,z]=r.useState(!1),ie=r.useCallback(async()=>{if(!(U||!M)){z(!0);try{await M()}finally{z(!1)}}},[U,M]),dt=r.useCallback(i=>{V.has(i)||(Me(x=>{const b=new Set(x);return b.add(i),b}),N?.(i),i===K&&ae(null))},[V,K,N]),hn=r.useCallback(i=>{_(`/${i.name} `),xe(!1),requestAnimationFrame(()=>{const x=re.current;x&&(x.focus(),x.setSelectionRange(x.value.length,x.value.length))})},[]),Hn=r.useCallback(i=>{_(i);const x=/^\/\S*$/.test(i)&&ot.length>0;xe(x)},[ot.length]),Kn=i=>{if(G&&fe.length>0){if(i.key==="ArrowDown"){i.preventDefault(),oe(x=>(x+1)%fe.length);return}if(i.key==="ArrowUp"){i.preventDefault(),oe(x=>(x-1+fe.length)%fe.length);return}if(i.key==="Tab"||i.key==="Enter"&&!i.shiftKey&&!_e.current){i.preventDefault(),hn(fe[Ce]);return}if(i.key==="Escape"){i.preventDefault(),xe(!1);return}}i.key==="Enter"&&!i.shiftKey&&!_e.current&&(i.preventDefault(),o())},Vn=r.useCallback(i=>{const x=Array.from(i.clipboardData?.items||[]).filter(b=>b.kind==="file"&&b.type.startsWith("image/")).map(b=>b.getAsFile()).filter(b=>!!b);x.length&&(i.preventDefault(),ct(x))},[ct]),ge=Te||n.agent||$.find(i=>i.isDefault)?.agent||$.find(i=>i.installed)?.agent||$[0]?.agent||"",Ot=$.find(i=>i.agent===ge)||null,ut=ne||ge,ht=$.find(i=>i.agent===ut)||Ot,Ct=r.useMemo(()=>{if(!ht)return[];const i=[];for(const b of ht.models||[])i.push({id:b.id,label:b.id,kind:"native",description:b.alias&&b.alias.toLowerCase()!==b.id.toLowerCase()?b.alias:void 0});const x=new Set(rs[ut]||[]);for(const b of ue){const S=at.find(me=>me.id===b.providerId);if(!S||!x.has(S.kind))continue;const R=b.name.trim().toLowerCase()!==b.modelId.trim().toLowerCase();i.push({id:b.modelId,label:b.name,kind:"profile",profileId:b.id,description:R?`${S.name} · ${b.modelId}`:S.name})}return i},[ht,ut,ue,at]),Gn=r.useMemo(()=>Ct.findIndex(i=>i.kind==="profile"),[Ct]),qn=kt[ut]||null,pn=!!n.agent&&ge===n.agent,pt=ke||pn&&n.model||""||Ot?.selectedModel||"",Et=ge==="gemini"?"":de||pn&&n.thinkingEffort||""||Ot?.selectedEffort||"";r.useEffect(()=>{O?.({model:pt||null,effort:Et||null})},[pt,Et,O]);const Qn=Vt[ut]||[],$e=Ue&&ee.find(i=>i.id===Ue)||null,Jn=$e?{key:$e.id,url:$e.previewUrl,name:$e.file.name,size:$e.file.size,file:$e.file,onRemove:()=>St($e.id)}:ze?{key:ze,url:ze}:null,xn=(!!H.trim()||ee.length>0)&&!I&&!!ge,Dt=()=>{le(null),ye(null),Ae(null),jt(void 0)},Ft=r.useCallback(async(i,x,b)=>{const S=i==="gemini"?"":b||"";if(Re!==void 0)try{await fetch(`/api/models/agents/${i}/active`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({profileId:Re})}),lt(),We()}catch{}tt(i),bt(x),vt(S),Dt(),se("closed")},[Re,lt,We]),Xn=()=>{W==="closed"?(Dt(),We(),lt(),se("agent")):(Dt(),se("closed"))},Ut=ne||ge,fn=Yt(Ut),zt=P??pt,Ge=X??Et,Yn=zt?sn(zt):"",qe=(()=>{const i=kt[Ut];return i?ue.find(x=>x.id===i)??null:null})(),Qe=qe?at.find(i=>i.id===qe.providerId)??null:null,Zn=Qe?Vs(Qe):null,Ht=qe&&qe.name.trim().toLowerCase()!==qe.modelId.trim().toLowerCase()?qe.name:Yn,es=[fn.shortLabel,Qe?Qe.name:null,Ht||null,Ge?Ge.charAt(0).toUpperCase()+Ge.slice(1):null].filter(Boolean).join(" / ");return e.jsxs("div",{className:"shrink-0",ref:wt,children:[e.jsxs("div",{className:"max-w-[680px] mx-auto px-5 pb-4 pt-2",children:[y&&e.jsxs("div",{className:"mb-2 space-y-1.5",children:[u&&e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-primary/20 bg-primary/[0.04] px-3.5 py-1.5 transition-colors",children:[e.jsx(he,{className:"h-3 w-3 text-primary shrink-0"}),e.jsx("span",{className:"flex-1 min-w-0 text-[12px] font-medium text-fg-3 truncate",children:c("hub.running")}),e.jsxs("button",{onClick:ie,disabled:U,title:c("hub.stopHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-err hover:bg-err/10 transition-colors disabled:opacity-30 disabled:pointer-events-none shrink-0",children:[U?e.jsx(he,{className:"h-2.5 w-2.5"}):e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"currentColor",children:e.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"2"})}),c("hub.stop")]})]}),h.map((i,x)=>{const b=x===h.length-1,S=h.length>1?`${c("hub.queued")} #${x+1}`:c("hub.queued"),R=E?.find(Y=>Y.taskId===i)||(b?E?.find(Y=>!Y.taskId):void 0),me=j?.find(Y=>Y.taskId===i)?.prompt||R?.prompt||null,be=R?.imageUrls?.length?R.imageUrls:[];return e.jsxs("div",{className:"flex items-center gap-2.5 rounded-lg border border-warn/25 bg-warn/[0.04] px-3.5 py-1.5 transition-colors",children:[e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-warn animate-pulse shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[e.jsx("span",{className:"text-[12px] font-medium text-warn shrink-0",children:S}),be.length>0&&e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[be.slice(0,3).map((Y,Kt)=>e.jsx("button",{type:"button",onClick:()=>nt(Y),title:c("hub.previewImage"),className:"block h-5 w-5 shrink-0 overflow-hidden rounded border border-warn/30 transition-opacity hover:opacity-80",children:e.jsx("img",{src:Y,alt:"",className:"h-full w-full object-cover"})},`${Y}-${Kt}`)),be.length>3&&e.jsxs("span",{className:"text-[10px] text-fg-5/60",children:["+",be.length-3]})]}),me&&e.jsx("span",{className:"text-[11px] text-fg-5/60 truncate",children:me})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsxs("button",{onClick:()=>dt(i),disabled:V.has(i),title:c("hub.steerHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-blue-400 hover:bg-blue-400/10 transition-colors disabled:opacity-30 disabled:pointer-events-none",children:[V.has(i)?e.jsx(he,{className:"h-2.5 w-2.5"}):e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),c("hub.steer")]}),e.jsxs("button",{onClick:()=>C(i),disabled:Z.has(i),title:c("hub.recallHint"),className:"flex items-center gap-1 px-2 py-1 rounded-md text-[11px] font-medium text-fg-4 hover:text-err hover:bg-err/10 transition-colors disabled:opacity-30 disabled:pointer-events-none",children:[Z.has(i)?e.jsx(he,{className:"h-2.5 w-2.5"}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]}),c("hub.recall")]})]})]},i)})]}),e.jsxs("div",{className:"relative rounded-xl border border-edge/40 bg-panel shadow-sm transition-[border-color,box-shadow] duration-200 focus-within:border-fg-5/40 focus-within:shadow-md",children:[e.jsx("input",{ref:st,type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:i=>{ct(i.target.files),i.target.value=""}}),ee.length>0&&e.jsx("div",{className:"px-3 pt-3",children:e.jsx("div",{className:"flex gap-2 overflow-x-auto pb-1",children:ee.map(i=>e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs("button",{type:"button",onClick:()=>Ie(i.id),title:c("hub.previewImage"),className:"group relative h-[72px] w-[72px] overflow-hidden rounded-lg border border-edge/30 bg-panel-alt/30",children:[e.jsx("img",{src:i.previewUrl,alt:i.file.name,className:"h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.03]"}),e.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 bg-gradient-to-t from-black/60 via-black/10 to-transparent px-1.5 pb-1 pt-3 text-left",children:e.jsx("div",{className:"truncate text-[8px] font-medium text-white/90 leading-tight",children:i.file.name})})]}),e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),St(i.id)},title:c("hub.removeImage"),className:"absolute -right-1 -top-1 flex h-5 w-5 items-center justify-center rounded-full border border-white/10 bg-black/65 text-white/75 transition-colors hover:bg-black/80 hover:text-white",children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]},i.id))})}),G&&fe.length>0&&e.jsxs("div",{ref:Pe,className:"absolute bottom-full left-0 right-0 mb-1.5 z-50 max-h-[200px] overflow-y-auto rounded-xl border border-edge/40 bg-[var(--th-dropdown)] backdrop-blur-xl shadow-lg animate-in",children:[e.jsx("div",{className:"px-3 pt-2 pb-1 border-b border-edge/20",children:e.jsx("span",{className:"text-[10px] font-semibold text-fg-5 uppercase tracking-wider",children:c("hub.skills")})}),e.jsx("div",{className:"py-1",children:fe.map((i,x)=>e.jsxs("button",{"data-skill-idx":x,onMouseDown:b=>{b.preventDefault(),hn(i)},onMouseEnter:()=>oe(x),className:L("flex flex-col w-full px-3 py-1.5 text-left transition-colors",x===Ce?"bg-panel-h text-fg":"text-fg-3 hover:bg-panel-alt/50"),children:[e.jsxs("span",{className:"text-[12.5px] font-medium",children:["/",i.name]}),(i.label||i.description)&&e.jsx("span",{className:"text-[11px] text-fg-5 truncate",children:i.label||i.description})]},i.name))})]}),e.jsx("textarea",{ref:re,value:H,onChange:i=>Hn(i.target.value),onPaste:Vn,onKeyDown:Kn,onCompositionStart:()=>{_e.current=!0},onCompositionEnd:()=>{_e.current=!1},placeholder:c("hub.inputPlaceholder"),rows:1,className:"w-full resize-none bg-transparent px-4 pt-3 pb-1 text-[13.5px] text-fg outline-none placeholder:text-fg-5/25 leading-[1.6]",style:{maxHeight:200,overflow:H.split(`
|
|
9
|
+
`).length>6?"auto":"hidden"}}),e.jsxs("div",{className:"flex items-center gap-1.5 px-2.5 pb-2 pt-1",children:[e.jsx("button",{type:"button",onClick:()=>st.current?.click(),title:c("hub.addImages"),className:"flex h-7 w-7 items-center justify-center rounded-lg text-fg-5/50 transition-colors hover:bg-panel-h/60 hover:text-fg-3",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.1",strokeLinecap:"round",children:[e.jsx("path",{d:"M12 5v14"}),e.jsx("path",{d:"M5 12h14"})]})}),e.jsxs("button",{ref:He,onClick:Xn,disabled:!$.length,title:$.length?es:void 0,className:L("flex items-center gap-1.5 h-[28px] px-2.5 rounded-lg text-[11px] font-medium transition-all duration-200 select-none",W!=="closed"?"bg-panel-h border border-edge-h text-fg-3":"text-fg-5/60 hover:text-fg-4 hover:bg-panel-h/50 border border-transparent"),children:[$.length?e.jsx(Xe,{brand:Ut,size:12}):e.jsx(he,{className:"h-3 w-3"}),$.length?e.jsxs("span",{className:"flex items-center gap-1 max-w-[460px] min-w-0 truncate",children:[e.jsx("span",{className:"shrink-0",children:fn.shortLabel}),Qe&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx(Xe,{brand:Zn||"custom",size:12}),e.jsx("span",{className:"shrink-0 truncate max-w-[140px]",children:Qe.name})]}),Ht&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx("span",{className:"truncate",title:zt||void 0,children:Ht})]}),Ge&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-fg-5/40 shrink-0",children:"/"}),e.jsx("span",{className:"shrink-0",children:Ge.charAt(0).toUpperCase()+Ge.slice(1)})]})]}):e.jsx("span",{className:"max-w-[420px] truncate",children:c("hub.selectAgent")}),e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:L("text-fg-5/30 transition-transform duration-200",W!=="closed"&&"rotate-180"),children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]}),W!=="closed"&&pe&&on.createPortal(e.jsxs("div",{id:"cascade-portal",className:"fixed z-[200] w-[300px] rounded-xl border border-edge/40 bg-[var(--th-dropdown)] backdrop-blur-xl shadow-lg overflow-hidden animate-in",style:{left:pe.left,bottom:pe.bottom},children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 pt-2.5 pb-1.5 border-b border-edge/20",children:[W!=="agent"&&e.jsx("button",{onClick:()=>{if(W==="effort"){const i=ht?.capabilities?.modelSwitch!==!1;se(i?"model":"agent")}else se("agent")},className:"p-0.5 rounded text-fg-5/50 hover:text-fg-3 transition-colors",children:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:e.jsx("polyline",{points:"15 18 9 12 15 6"})})}),e.jsx("span",{className:"text-[10px] font-semibold text-fg-5 uppercase tracking-wider",children:c(W==="agent"?"hub.selectAgent":W==="model"?"hub.selectModel":"hub.selectEffort")}),e.jsx("div",{className:"ml-auto flex items-center gap-0.5",children:(()=>{const x=ht?.capabilities?.modelSwitch!==!1?["agent","model","effort"]:["agent","effort"],b=x.indexOf(W);return x.map((S,R)=>e.jsx("span",{className:L("w-1.5 h-1.5 rounded-full transition-colors",W===S?"bg-primary":R<b?"bg-primary/40":"bg-fg-5/15")},S))})()})]}),e.jsxs("div",{className:"max-h-[200px] overflow-y-auto py-1",children:[W==="agent"&&$.filter(i=>i.installed).map(i=>{const x=Yt(i.agent),b=os(i.usage),S=b?is(b):"ok";return e.jsxs(Jt,{selected:i.agent===(ne||ge),onClick:()=>{if(le(i.agent),ye(i.selectedModel||""),Ae(i.selectedEffort||""),!(i.capabilities?.modelSwitch!==!1)){(Vt[i.agent]||[]).length?se("effort"):Ft(i.agent,i.selectedModel||"",null);return}se("model")},children:[e.jsx(Xe,{brand:i.agent,size:14}),e.jsx("span",{style:{color:x.color},children:x.label}),b&&e.jsxs("span",{className:L("ml-auto font-mono text-[10px]",S==="err"?"text-err":S==="warn"?"text-warn":"text-fg-5"),children:[b.label," ",Math.round(b.usedPercent??0),"%"]})]},i.agent)}),W==="model"&&e.jsxs(e.Fragment,{children:[Ct.map((i,x)=>{const b=x===0&&i.kind==="native",S=x===Gn&&i.kind==="profile",R=Re!==void 0?Re:qn,me=i.kind==="profile"?!!i.profileId&&i.profileId===R:!R&&i.id===(P??pt);return e.jsxs("div",{children:[b&&e.jsx("div",{className:"px-3 pb-1 pt-1.5 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:c("hub.modelGroupNative")}),S&&e.jsx("div",{className:"px-3 pb-1 pt-2 text-[10px] font-medium uppercase tracking-wide text-fg-5",children:c("hub.modelGroupProfiles")}),e.jsx(Jt,{selected:me,onClick:()=>{const be=ne||ge;if(ye(i.id),jt(i.profileId??null),Vt[be]?.length){se("effort");return}Ft(be,i.id,null)},children:e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:L("truncate text-[11.5px]",i.kind==="native"&&"font-mono text-[11px]"),title:i.id,children:i.label}),i.description&&e.jsx("div",{className:"truncate text-[10px] text-fg-5/80",children:i.description})]})})]},`${i.kind}:${i.profileId||i.id}`)}),Ct.length===0&&e.jsx("div",{className:"px-3 py-3 text-[11px] text-fg-5 text-center",children:c("config.noModel")})]}),W==="effort"&&Qn.map(i=>e.jsx(Jt,{selected:i===(X||Et),onClick:()=>{Ae(i),Ft(ne||ge,P??pt,i)},children:i.charAt(0).toUpperCase()+i.slice(1)},i))]})]}),document.body),e.jsx("div",{className:"flex-1"}),e.jsx("button",{onClick:o,disabled:!xn,className:L("flex items-center justify-center w-[30px] h-[30px] rounded-lg transition-all duration-200",xn?"bg-primary text-primary-fg hover:brightness-110 shadow-sm":"bg-fg/6 text-fg-5/20"),children:I?e.jsx(he,{className:"h-3.5 w-3.5"}):e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),e.jsx("polyline",{points:"5 12 12 5 19 12"})]})})]})]})]}),e.jsx(qs,{source:Jn,onClose:()=>{Ie(null),nt(null)},t:c})]})});function qs({source:t,onClose:n,t:s}){const[a,l]=r.useState(!1);if(r.useEffect(()=>{l(!1)},[t?.key]),r.useEffect(()=>{if(!t)return;const c=m=>{m.key==="Escape"&&n()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,n]),!t)return null;const d=t.file,p=t.onRemove;return on.createPortal(e.jsx("div",{className:"fixed inset-0 z-[220] flex items-center justify-center bg-black/72 px-4 py-6 backdrop-blur-sm",onClick:n,children:e.jsxs("div",{className:"w-full max-w-[1024px]",onClick:c=>c.stopPropagation(),children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-[11px] text-white/72",children:[t.name&&e.jsx("span",{className:"truncate font-medium text-white/90",children:t.name}),typeof t.size=="number"&&e.jsx("span",{children:Ds(t.size)}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[d&&e.jsx("button",{type:"button",onClick:async()=>{await Fs(d)&&(l(!0),window.setTimeout(()=>l(!1),1600))},className:"rounded-lg border border-white/12 bg-white/10 px-3 py-1.5 text-[11px] font-medium text-white/88 transition-colors hover:bg-white/14",children:s(a?"hub.copied":"hub.copyImage")}),p&&e.jsx("button",{type:"button",onClick:p,className:"rounded-lg border border-white/12 bg-white/10 px-3 py-1.5 text-[11px] font-medium text-white/88 transition-colors hover:bg-white/14",children:s("hub.removeImage")}),e.jsx("button",{type:"button",onClick:n,className:"flex h-9 w-9 items-center justify-center rounded-full border border-white/12 bg-white/10 text-white/88 transition-colors hover:bg-white/14",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.2",strokeLinecap:"round",children:[e.jsx("path",{d:"M18 6 6 18"}),e.jsx("path",{d:"M6 6l12 12"})]})})]})]}),e.jsx("div",{className:"overflow-hidden rounded-xl border border-white/10 bg-black/35 shadow-[0_20px_70px_rgba(0,0,0,0.45)]",children:e.jsx("img",{src:t.url,alt:t.name||"",className:"max-h-[80vh] w-full object-contain"})})]})}),document.body)}function Jt({selected:t,onClick:n,children:s}){return e.jsxs("button",{onClick:n,className:L("flex items-center gap-2 w-full px-3 py-2 text-[12px] text-left transition-colors",t?"text-fg bg-panel-h font-medium":"text-fg-3 hover:bg-panel-alt/50 hover:text-fg-2"),children:[s,t&&e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:"ml-auto text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}),!t&&e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"ml-auto text-fg-5/20",children:e.jsx("polyline",{points:"9 6 15 12 9 18"})})]})}function Qs(){return function(t){fs(t)}}const dn=[gs,Qs],Js=t=>/^https?:\/\//.test(t),bn=t=>/^(\/|~\/|\.\.?\/)/.test(t);function Xs({text:t}){const[n,s]=r.useState(!1),a=()=>{navigator.clipboard.writeText(t).then(()=>{s(!0),setTimeout(()=>s(!1),2e3)}).catch(()=>{})};return e.jsx("button",{onClick:a,className:"flex items-center text-fg-5/50 hover:text-fg-3 transition-colors",children:n?e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})})}function vn(t){const n=/^[.~/].*\.\w+$/.test(t)||/^[a-z][\w-]*\//.test(t),s=/^(npm |npx |git |python|pip |yarn |pnpm |cargo |go |make )/.test(t);return n?"bg-blue-500/8 border-blue-400/12 text-blue-300/90":s?"bg-amber-500/8 border-amber-400/10 text-amber-300/80":"bg-[rgba(255,255,255,0.06)] border-edge/20 text-fg-3"}const un={h1:({children:t})=>e.jsx("h2",{className:"text-[16px] font-bold text-fg mt-4 mb-2",children:t}),h2:({children:t})=>e.jsx("h3",{className:"text-[14.5px] font-semibold text-fg mt-4 mb-1.5",children:t}),h3:({children:t})=>e.jsx("h4",{className:"text-[13.5px] font-semibold text-fg mt-3 mb-1",children:t}),p:({children:t})=>e.jsx("p",{className:"my-1.5 whitespace-pre-wrap break-words",children:t}),strong:({children:t})=>e.jsx("strong",{className:"font-semibold text-fg",children:t}),em:({children:t})=>e.jsx("em",{className:"italic text-fg-3",children:t}),a:({href:t,children:n})=>t&&Js(t)?e.jsx("a",{href:t,target:"_blank",rel:"noopener noreferrer",className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30 cursor-pointer hover:text-blue-300 transition-colors",children:n}):t&&bn(t)?e.jsx("span",{className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30 cursor-pointer hover:text-blue-300 transition-colors",onClick:()=>J.openInEditor(t),children:n}):e.jsx("span",{className:"text-blue-400 underline underline-offset-2 decoration-blue-400/30",children:n}),ul:({children:t})=>e.jsx("ul",{className:"space-y-1 my-2 ml-1",children:t}),ol:({children:t})=>e.jsx("ol",{className:"space-y-1 my-2 ml-1 list-decimal list-inside",children:t}),li:({children:t})=>e.jsxs("li",{className:"flex gap-2 items-start",children:[e.jsx("span",{className:"shrink-0 mt-[10px] w-[5px] h-[5px] rounded-full bg-fg-5/40"}),e.jsx("span",{className:"flex-1",children:t})]}),blockquote:({children:t})=>e.jsx("blockquote",{className:"border-l-2 border-fg-5/30 pl-3 my-2 text-fg-4 italic",children:t}),hr:()=>e.jsx("hr",{className:"border-edge/30 my-4"}),code:({className:t,children:n,...s})=>{const a=String(n).replace(/\n$/,""),l=/language-(\w+)/.exec(t||"");if(!l&&!t&&!a.includes(`
|
|
10
|
+
`))return bn(a)?e.jsx("code",{className:L("px-1.5 py-[1px] rounded text-[12px] font-mono border cursor-pointer hover:brightness-125 transition-all",vn(a)),onClick:()=>J.openInEditor(a),children:a}):e.jsx("code",{className:L("px-1.5 py-[1px] rounded text-[12px] font-mono border",vn(a)),children:a});const d=l?.[1]||"";return e.jsxs("div",{className:"rounded-lg overflow-hidden border border-edge/30 bg-[rgba(0,0,0,0.25)] my-3 not-prose",children:[e.jsxs("div",{className:"flex items-center justify-between px-3.5 py-1.5 border-b border-edge/15 bg-[rgba(0,0,0,0.12)]",children:[e.jsx("span",{className:"text-[10px] font-mono text-fg-5/50",children:d||"text"}),e.jsx(Xs,{text:a})]}),e.jsx("pre",{className:"px-3.5 py-3 text-[12px] leading-[1.65] text-fg-3 font-mono whitespace-pre-wrap break-words overflow-x-auto",children:e.jsx("code",{children:a})})]})},pre:({children:t})=>e.jsx(e.Fragment,{children:t}),table:({children:t})=>e.jsx("div",{className:"my-3 overflow-x-auto rounded-lg border border-edge/30",children:e.jsx("table",{className:"w-full text-[12.5px]",children:t})}),thead:({children:t})=>e.jsx("thead",{className:"bg-[rgba(0,0,0,0.1)]",children:t}),th:({children:t})=>e.jsx("th",{className:"px-3 py-1.5 text-left font-semibold text-fg-3 border-b border-edge/30",children:t}),td:({children:t})=>e.jsx("td",{className:"px-3 py-1.5 text-fg-4 border-t border-edge/12",children:t}),tr:({children:t})=>e.jsx("tr",{className:"even:bg-[rgba(255,255,255,0.015)]",children:t})};function et(t){return!!t?.steps?.length}function Ys(t,n){let s=t;for(const[a,l]of Object.entries(n))s=s.replace(new RegExp(`\\{${a}\\}`,"g"),l);return s}function Zs({status:t}){return t==="completed"?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",className:"text-ok",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):t==="inProgress"?e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-cyan-400 animate-pulse"}):e.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-fg-5/25"})}function _n({plan:t,t:n,className:s}){const[a,l]=r.useState(!1);if(!et(t))return null;const d=t.steps.length,p=t.steps.filter(v=>v.status==="completed").length,c=d>0&&p===d,m=Ys(n("hub.planProgress"),{done:String(p),total:String(d)});return e.jsx(Ze,{open:a,onToggle:()=>l(v=>!v),dot:{color:c?"bg-emerald-400/60":"bg-cyan-400/60",pulse:!c},label:m,preview:t.explanation?e.jsx("span",{className:"text-[11.5px] text-fg-4 truncate",children:t.explanation}):void 0,badge:e.jsx("span",{className:L("rounded-md border px-1.5 py-0.5 text-[10px] font-mono",c?"border-ok/20 text-ok":"border-edge text-fg-5"),children:n(c?"hub.planDone":"hub.planInProgress")}),className:s,children:e.jsx("div",{className:"px-3.5 py-2.5 space-y-1",children:t.steps.map((v,g)=>{const j=v.status==="completed"?"text-fg-5 line-through decoration-fg-5/40":v.status==="inProgress"?"text-fg-3":"text-fg-4";return e.jsxs("div",{className:"flex items-center gap-2 py-[2px]",children:[e.jsx("span",{className:"shrink-0 flex items-center justify-center w-[10px]",children:e.jsx(Zs,{status:v.status})}),e.jsx("span",{className:L("text-[12px] leading-[1.5]",j),children:v.step})]},`${g}:${v.step}`)})})})}function Pn(t){return!!t.text||!!t.thinking||!!(t.activity&&t.activity.split(`
|
|
11
|
+
`).filter(Boolean).length)||!!t.previewMeta?.toolCalls?.length||et(t.plan)||!!(t.subAgents&&t.subAgents.length)}function Yr(t){return Pn(t)||t.phase==="streaming"?!0:t.phase==="done"&&!!t.error}function er(t){return t.phase!=="done"||!t.error?null:Pn(t)?"hub.streamErrored":"hub.streamFailed"}function tr({detail:t,t:n,className:s}){const a=$s(t);if(a==="interrupted")return e.jsxs("div",{className:L("flex items-center gap-1.5 text-[11px] text-fg-5/55",s),children:[e.jsx("span",{className:"inline-block h-2 w-2 rounded-[2px] bg-fg-5/45 shrink-0"}),e.jsx("span",{children:n("hub.turnStopped")})]});const l=a==="error"?{dot:"bg-rose-400/55",text:"text-rose-300/65"}:{dot:"bg-fg-5/40",text:"text-fg-5/55"};return e.jsxs("div",{className:L("flex items-start gap-1.5 text-[11px] leading-[1.6]",l.text,s),children:[e.jsx("span",{className:L("mt-[5px] h-1 w-1 rounded-full shrink-0",l.dot)}),e.jsx("span",{className:"min-w-0 break-words",children:t})]})}function Zr({stream:t,t:n}){const s=et(t.plan),[a,l]=r.useState(!1),[d,p]=r.useState(!1),c=r.useRef(null),m=r.useRef(null),v=er(t),g=r.useMemo(()=>(t.activity||"").split(`
|
|
12
|
+
`).filter(Boolean),[t.activity]),j=t.previewMeta?.toolCalls??[],E=g[g.length-1]||j[j.length-1]?.summary||"";r.useLayoutEffect(()=>{const N=c.current;N&&a&&(N.scrollTop=N.scrollHeight)},[a,t.activity,j.length]),r.useLayoutEffect(()=>{const N=m.current;N&&d&&(N.scrollTop=N.scrollHeight)},[d,t.thinking]);const k=t.subAgents??null;return e.jsxs("div",{className:"space-y-3 animate-in",children:[s&&e.jsx(_n,{plan:t.plan,t:n,className:"mb-1 max-w-[760px]"}),k&&k.length>0&&k.map(N=>e.jsx(Wn,{sub:N,t:n},N.id)),(j.length>0||g.length>0)&&e.jsx(Ze,{open:a,onToggle:()=>l(N=>!N),dot:{color:"bg-cyan-400/60",pulse:!0},label:n("hub.activity"),preview:e.jsx("span",{className:"text-[12px] text-fg-4 truncate",children:E}),badge:(j.length||g.length)>1?e.jsx(rn,{children:j.length||g.length}):void 0,children:e.jsx("div",{ref:c,className:"px-3.5 py-2.5 space-y-0.5 max-h-[280px] overflow-y-auto",children:j.length>0?j.map(N=>e.jsx(nr,{call:N},N.id)):g.map((N,M)=>e.jsxs("div",{className:"flex items-center gap-1.5 py-[2px]",children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0 bg-fg-5/30"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 truncate",children:N})]},M))})}),t.thinking&&e.jsx(Ze,{open:d,onToggle:()=>p(N=>!N),dot:{color:"bg-violet-400/50",pulse:!0},label:n("hub.thinking"),collapsedContent:e.jsx("div",{className:"px-3.5 pb-2.5 -mt-0.5 text-[12px] text-fg-4 leading-[1.65] whitespace-pre-wrap break-words line-clamp-3",children:An(t.thinking,3)}),children:e.jsx("div",{ref:m,className:"px-3.5 py-3 text-[12px] text-fg-4 leading-[1.7] whitespace-pre-wrap break-words max-h-[280px] overflow-y-auto",children:t.thinking})}),t.text&&e.jsxs("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:[e.jsx(an,{remarkPlugins:dn,components:un,children:t.text}),t.phase==="streaming"&&e.jsx(en,{className:"ml-1 inline-flex align-text-bottom text-fg-4"})]}),!t.text&&t.phase==="streaming"&&e.jsx("div",{className:"py-1",children:e.jsx(en,{className:"text-fg-5"})}),t.phase==="streaming"&&(t.generatingImages??0)>0&&e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-fg-4",children:[e.jsxs("span",{className:"relative inline-flex items-center justify-center w-3 h-3",children:[e.jsx("span",{className:"absolute inline-flex w-3 h-3 rounded-full bg-cyan-400/40 animate-ping"}),e.jsx("span",{className:"relative inline-block w-1.5 h-1.5 rounded-full bg-cyan-400/80"})]}),e.jsx("span",{children:t.generatingImages===1?"Generating image…":`Generating ${t.generatingImages} images…`})]}),v&&t.error&&e.jsx(tr,{detail:t.error,t:n,className:"pt-0.5"})]})}function nr({call:t}){const[n,s]=r.useState(!1),a=!!(t.input||t.result),l=t.status==="failed"?"bg-rose-400/70":t.status==="running"?"bg-cyan-400/70":"bg-fg-5/30";return e.jsxs("div",{children:[e.jsxs("button",{type:"button",onClick:()=>a&&s(d=>!d),className:`flex w-full items-center gap-1.5 py-[2px] text-left min-w-0 ${a?"cursor-pointer hover:bg-white/[0.03] rounded":"cursor-default"}`,title:a?void 0:t.summary,children:[e.jsx("span",{className:`w-1 h-1 rounded-full shrink-0 ${l} ${t.status==="running"?"animate-pulse":""}`}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 truncate flex-1",children:t.summary}),a&&e.jsx("span",{className:`shrink-0 text-[9px] text-fg-5/40 transition-transform ${n?"rotate-90":""}`,children:"▸"})]}),n&&e.jsxs("div",{className:"ml-2.5 mt-0.5 mb-1 space-y-1 border-l border-white/[0.06] pl-2.5",children:[t.input&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-[10.5px] font-mono leading-[1.55] text-fg-4/80 max-h-[140px] overflow-y-auto",children:t.input}),t.result&&e.jsx("pre",{className:"whitespace-pre-wrap break-words text-[10.5px] font-mono leading-[1.55] text-fg-5/70 max-h-[140px] overflow-y-auto border-t border-white/[0.04] pt-1",children:t.result})]})]})}function en({className:t}){return e.jsxs("span",{className:`thinking-dots inline-flex items-center gap-[3px] ${t||""}`,children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]})}function Wn({sub:t,t:n}){const[s,a]=r.useState(!1),l=t.status,d=l==="failed"?"bg-rose-400/60":l==="done"?"bg-emerald-400/55":"bg-amber-400/60",p=l==="running",c=t.tools,m=r.useMemo(()=>{const j=new Set,E=[];for(const k of c)j.has(k.name)||(j.add(k.name),E.push(k.name));return E},[c]),v=t.kind?`${n("hub.subAgent")||"Sub-agent"} · ${t.kind}`:n("hub.subAgent")||"Sub-agent",g=t.model?sn(t.model):null;return e.jsx(Ze,{open:s,onToggle:()=>a(j=>!j),dot:{color:d,pulse:p},label:v,preview:e.jsxs("span",{className:"flex items-center gap-1.5 min-w-0 text-[12px] text-fg-4",children:[t.description&&e.jsx("span",{className:"truncate",children:t.description}),g&&e.jsx("span",{className:"text-[10px] font-mono text-fg-5/55 shrink-0",children:g}),!t.description&&m.length>0&&e.jsx("span",{className:"font-mono text-fg-5/60 truncate",children:m.join(" · ")})]}),badge:c.length>0?e.jsx(rn,{children:c.length}):void 0,children:e.jsxs("div",{className:"px-3.5 py-2.5 space-y-1 max-h-[260px] overflow-y-auto",children:[t.description&&e.jsx("div",{className:"mb-1.5 text-[12px] text-fg-3 leading-[1.55]",children:t.description}),c.length===0?e.jsxs("div",{className:"text-[11px] font-mono text-fg-5/50",children:["— ",n("hub.subAgentWaiting")||"waiting for first tool…"]}):c.map(j=>e.jsxs("div",{className:"flex items-center gap-1.5 py-[2px]",children:[e.jsx("span",{className:"w-1 h-1 rounded-full shrink-0 bg-fg-5/30"}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/65 truncate",children:j.summary})]},j.id))]})})}function sr({message:t,t:n}){const{activityBlocks:s,thinkingBlocks:a,planBlocks:l,subAgentBlocks:d,outputBlocks:p,noticeBlocks:c}=Bn(t.blocks),m=[...l].reverse().find(g=>et(g.plan));return s.length>0||d.length>0||!!m?.plan||a.length>0||p.length>0||c.length>0?e.jsxs("div",{className:"space-y-3",children:[s.length>0&&e.jsx(ir,{blocks:s,t:n}),d.map(g=>g.subAgent?e.jsx(Wn,{sub:g.subAgent,t:n},g.toolId||g.subAgent.id):null),m?.plan&&e.jsx(_n,{plan:m.plan,t:n,className:"max-w-[760px]"}),a.length>0&&e.jsx(lr,{blocks:a,t:n}),p.length>0&&e.jsx(ur,{blocks:p,t:n}),c.length>0&&e.jsx(or,{blocks:c,t:n})]}):null}function rr(t){const{activityBlocks:n,thinkingBlocks:s,planBlocks:a,subAgentBlocks:l,outputBlocks:d,noticeBlocks:p}=Bn(t.blocks);return d.length>0||n.length>0||l.length>0||s.length>0||a.some(c=>et(c.plan))||p.length>0}function Bn(t){const n=t.filter(s=>s.type==="plan"||s.type==="tool_use"||s.type==="tool_result"||s.type==="image"||s.type==="sub_agent"||!!s.content.trim());return{activityBlocks:n.filter(s=>s.type==="tool_use"||s.type==="tool_result"),thinkingBlocks:n.filter(s=>s.type==="thinking"),planBlocks:n.filter(s=>s.type==="plan"&&et(s.plan)),subAgentBlocks:n.filter(s=>s.type==="sub_agent"),outputBlocks:n.filter(s=>s.type==="text"||s.type==="image"),noticeBlocks:n.filter(s=>s.type==="system_notice")}}function or({blocks:t,t:n}){const s=t.map(a=>a.content).filter(Boolean).join(`
|
|
13
|
+
|
|
14
|
+
`).trim();return s?e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-amber-500/30 bg-amber-500/[0.06] px-3 py-2 text-[12.5px] leading-[1.7] text-fg-3",children:[e.jsx("span",{className:"mt-[6px] h-1.5 w-1.5 rounded-full bg-amber-400/70 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[11px] font-mono uppercase tracking-wide text-amber-300/80",children:n("hub.systemNotice")||"Agent notice"}),e.jsx("div",{className:"mt-0.5 break-words whitespace-pre-wrap",children:s})]})]}):null}function ir({blocks:t,t:n}){const[s,a]=r.useState(!1),l=t.filter(m=>m.type==="tool_use"),d=l.length,p=l[l.length-1],c=p?Rn(p):"";return e.jsx(Ze,{open:s,onToggle:()=>a(m=>!m),dot:{color:"bg-cyan-400/60"},label:n("hub.activity"),preview:e.jsx("span",{className:"text-[11.5px] font-mono text-fg-4 truncate",children:c}),badge:d>0?e.jsx(rn,{children:d}):void 0,children:e.jsx("div",{className:"px-3.5 py-2.5 space-y-0.5",children:t.map((m,v)=>e.jsx(ar,{block:m},v))})})}function ar({block:t}){const[n,s]=r.useState(!1),a=t.type==="tool_use",l=a?Rn(t):zs(t);return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>t.content&&s(d=>!d),className:L("flex items-center gap-2 py-[3px] w-full text-left group rounded-sm transition-colors",t.content&&"hover:bg-panel-h/30"),children:[e.jsx("span",{className:L("h-1.5 w-1.5 rounded-full shrink-0",a?"bg-fg-5/40":"bg-ok/40")}),e.jsx("span",{className:"text-[11px] font-mono text-fg-5/60 group-hover:text-fg-3 transition-colors truncate",children:l})]}),n&&t.content&&e.jsx("pre",{className:"ml-3 mt-1 mb-2 p-3 rounded-md bg-inset border border-edge text-[11px] leading-[1.6] text-fg-4 font-mono whitespace-pre-wrap break-words max-h-[240px] overflow-y-auto",children:t.content.length>3e3?t.content.slice(0,3e3)+`
|
|
15
|
+
…`:t.content})]})}function lr({blocks:t,t:n}){const[s,a]=r.useState(!1),l=r.useRef(null),d=t.map(c=>c.content).filter(Boolean).join(`
|
|
16
|
+
|
|
17
|
+
`).trim();if(!d)return null;const p=An(d,3);return e.jsx(Ze,{open:s,onToggle:()=>a(c=>!c),dot:{color:"bg-violet-400/50"},label:n("hub.thinking"),collapsedContent:p?e.jsx("div",{className:"px-3.5 pb-2.5 -mt-0.5 text-[12px] text-fg-4 leading-[1.65] whitespace-pre-wrap break-words line-clamp-3",children:p}):void 0,children:e.jsx(cr,{scrollRef:l,text:d})})}function cr({scrollRef:t,text:n}){return r.useLayoutEffect(()=>{const s=t.current;s&&(s.scrollTop=s.scrollHeight)},[t]),e.jsx("div",{ref:t,className:"px-3.5 py-3 text-[12px] text-fg-4 leading-[1.7] whitespace-pre-wrap break-words max-h-[320px] overflow-y-auto",children:n})}function dr({block:t,onLightbox:n,t:s}){const a=t.imageCaption?.trim()||"",[l,d]=r.useState(!1);return e.jsxs("figure",{className:"flex flex-col gap-1.5 max-w-[400px]",children:[e.jsx("img",{src:t.content,alt:a||"",className:"max-w-[400px] max-h-[300px] rounded-md border border-fg-6/50 object-contain cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>n(t.content)}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{type:"button",onClick:()=>d(p=>!p),"aria-expanded":l,className:L("self-start inline-flex items-center gap-1 px-2 py-[3px] rounded-md","text-[11px] font-medium tracking-wide","border border-fg-6/40 bg-fg-6/[0.06] text-fg-3","hover:bg-fg-6/[0.12] hover:text-fg-2 hover:border-fg-6/60","transition-colors"),title:s(l?"hub.imagePromptHide":"hub.imagePromptShow"),children:[e.jsx("span",{"aria-hidden":!0,className:"text-[9px] leading-none",children:l?"▾":"▸"}),e.jsx("span",{children:s("hub.imagePrompt")})]}),l&&e.jsx("div",{className:"rounded-md border border-fg-6/30 bg-fg-6/[0.05] px-3 py-2 max-w-[400px] max-h-[260px] overflow-y-auto",children:e.jsx("div",{className:"text-[11.5px] leading-[1.65] text-fg-3 whitespace-pre-wrap break-words",children:a})})]})]})}function ur({blocks:t,t:n}){const s=t.filter(c=>c.type==="text"),a=t.filter(c=>c.type==="image"),l=s.map(c=>c.content).filter(Boolean).join(`
|
|
18
|
+
|
|
19
|
+
`),[d,p]=r.useState(null);return!l.trim()&&a.length===0?null:e.jsxs(e.Fragment,{children:[l.trim()&&e.jsx("div",{className:"session-md text-[13.5px] leading-[1.75] text-fg-2",children:e.jsx(an,{remarkPlugins:dn,components:un,children:l})}),a.length>0&&e.jsx("div",{className:"flex flex-wrap gap-3 mt-2",children:a.map((c,m)=>e.jsx(dr,{block:c,onLightbox:p,t:n},m))}),d&&e.jsx($n,{src:d,onClose:()=>p(null)})]})}const eo=r.memo(function({turn:n,turnIndex:s,agent:a,meta:l,model:d,effort:p,providerName:c,t:m,onResend:v,onEdit:g,onFork:j}){const E=n.user&&In(n.user.text),k=j&&typeof s=="number"?()=>j(s):void 0,N=!!n.assistant&&rr(n.assistant);return e.jsxs("div",{className:"session-turn",children:[n.user&&!E&&e.jsx(On,{text:n.user.text,blocks:n.user.blocks,t:m,onResend:v,onEdit:g,onFork:k}),E&&n.user&&!n.assistant&&e.jsx("div",{className:"mb-4 px-4 py-3 rounded-lg bg-[rgba(255,255,255,0.02)] border border-edge/20 text-[12.5px] leading-[1.7] text-fg-4",children:e.jsx(an,{remarkPlugins:dn,components:un,children:n.user.text})}),N&&e.jsxs(e.Fragment,{children:[e.jsx(fr,{agent:a,meta:l,model:d,effort:p,providerName:c,previewMeta:n.assistant.usage??null}),e.jsx("div",{className:"mb-6",children:e.jsx(sr,{message:n.assistant,t:m})})]})]})});function $n({src:t,onClose:n}){return r.useEffect(()=>{const s=a=>{a.key==="Escape"&&n()};return window.addEventListener("keydown",s),()=>window.removeEventListener("keydown",s)},[n]),on.createPortal(e.jsx("div",{className:"fixed inset-0 z-[9999] flex items-center justify-center bg-black/80 backdrop-blur-sm cursor-zoom-out",onClick:n,children:e.jsx("img",{src:t,className:"max-w-[90vw] max-h-[90vh] object-contain rounded-lg shadow-2xl",onClick:s=>s.stopPropagation()})}),document.body)}const hr=1500,pr=16,jn=8;function xr(t){const n=t.split(`
|
|
20
|
+
`);return n.length<=jn?t:n.slice(0,jn).join(`
|
|
21
|
+
`)}function On({text:t,blocks:n,t:s,onResend:a,onEdit:l,onFork:d}){const[p,c]=r.useState(!1),[m,v]=r.useState(!1),[g,j]=r.useState(null),E=t?t.split(`
|
|
22
|
+
`).length:0,k=!!t&&(t.length>hr||E>pr),[N,M]=r.useState(!1),A=t?k&&!N?xr(t):t:"",B=!!(a||l||d),O=n?.filter(I=>I.type==="image")||[],H=()=>{navigator.clipboard.writeText(t).then(()=>{v(!0),setTimeout(()=>v(!1),1500)}).catch(()=>{})},_=s("hub.expand").replace("{chars}",t?t.length.toLocaleString():"0").replace("{lines}",String(E));return e.jsxs("div",{className:"flex flex-col items-end mb-5 group/bubble",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[e.jsxs("div",{className:"max-w-[72%] rounded-md border border-fg-6 bg-panel px-4 py-3 text-[13.5px] leading-[1.72] text-fg shadow-sm",children:[t&&e.jsxs("div",{className:"whitespace-pre-wrap break-words",children:[A,k&&!N&&e.jsx("span",{className:"text-fg-5/60",children:"…"})]}),k&&e.jsx("button",{type:"button",onClick:()=>M(I=>!I),className:"mt-2 text-[11.5px] text-fg-4 hover:text-fg-2 underline decoration-fg-5/40 underline-offset-2 transition-colors",children:N?s("hub.collapse"):_}),O.length>0&&e.jsx("div",{className:L("flex flex-wrap gap-2",t&&"mt-2"),children:O.map((I,D)=>e.jsx("img",{src:I.content,className:"max-w-[280px] max-h-[200px] rounded border border-fg-6/50 object-cover cursor-zoom-in hover:opacity-90 transition-opacity",onClick:()=>j(I.content)},D))})]}),g&&e.jsx($n,{src:g,onClose:()=>j(null)}),B&&e.jsxs("div",{className:L("flex items-center gap-1 mt-1.5 mr-1 transition-all duration-200",p?"opacity-100 translate-y-0":"opacity-0 -translate-y-1 pointer-events-none"),children:[e.jsx(Mt,{label:s(m?"hub.copied":"hub.copy"),onClick:H,children:m?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"#34d399",strokeWidth:"2",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}),a&&e.jsx(Mt,{label:s("hub.rerun"),onClick:()=>a(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),l&&e.jsx(Mt,{label:s("hub.edit"),onClick:()=>l(t),children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("path",{d:"M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7"}),e.jsx("path",{d:"M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z"})]})}),d&&e.jsx(Mt,{label:s("hub.fork"),onClick:d,children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]})})]})]})}function Mt({label:t,onClick:n,children:s}){return e.jsx("button",{onClick:n,title:t,className:"flex items-center justify-center w-7 h-7 rounded border border-fg-6 bg-panel text-fg-4 shadow-sm hover:text-fg-2 hover:border-edge-h hover:bg-panel-h transition-colors",children:s})}function fr({agent:t,meta:n,model:s,effort:a,providerName:l,previewMeta:d,liveStartedAt:p}){const c=d?.contextPercent??null,m=d?.contextUsedTokens??0,v=d?.turnOutputTokens??0,g=c!=null||m>0||v>0,j=p!=null&&p>0,E=d?.providerName??l??null;return e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 mb-3",children:[e.jsx(Xe,{brand:t,size:13}),e.jsx("span",{style:{color:n.color},className:"text-[12px] font-semibold opacity-70",children:n.label}),(s||a)&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/50",children:[s||"",s&&a?" · ":"",a||""]}),E&&e.jsxs("span",{className:"text-[10px] font-mono text-fg-5/70 px-1.5 py-px rounded bg-fg-5/8",title:`This turn is routed through ${E} (BYOK), not the agent CLI's native auth.`,children:["via ",E]}),(g||j)&&e.jsxs("span",{className:"ml-auto inline-flex items-center gap-1 text-[10px] font-mono text-fg-5/55",title:vr(d),children:[c!=null&&e.jsx(jr,{pct:c}),e.jsx("span",{children:c!=null?`${c.toFixed(1)}%`:""}),m>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ",br(m)]}),v>0&&e.jsxs("span",{className:"text-fg-5/40",children:["· ↑",Dn(v)]}),j&&e.jsx(gr,{startedAt:p,leadingDot:g})]})]})}function gr({startedAt:t,leadingDot:n}){const[,s]=r.useState(0);r.useEffect(()=>{const l=setInterval(()=>s(d=>d+1),1e3);return()=>clearInterval(l)},[]);const a=Math.max(0,Date.now()-t);return e.jsxs("span",{className:"text-fg-5/55 tabular-nums",title:"Elapsed time of the running turn",children:[n?"· ":"",mr(a)]})}function mr(t){const n=Math.floor(t/1e3);if(n<60)return`${n}s`;const s=Math.floor(n/60),a=n%60;return s<60?`${s}m${a.toString().padStart(2,"0")}s`:`${Math.floor(s/60)}h${(s%60).toString().padStart(2,"0")}m`}function br(t){return`${Dn(t)} tok`}function Dn(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}k`:`${t}`}function vr(t){if(!t)return"";const n=[];return t.contextPercent!=null&&n.push(`Context: ${t.contextPercent.toFixed(1)}%`),t.inputTokens!=null&&n.push(`Input: ${t.inputTokens.toLocaleString()}`),t.turnOutputTokens!=null?n.push(`Output (turn): ${t.turnOutputTokens.toLocaleString()}`):t.outputTokens!=null&&n.push(`Output: ${t.outputTokens.toLocaleString()}`),t.cachedInputTokens!=null&&n.push(`Cached: ${t.cachedInputTokens.toLocaleString()}`),n.join(" · ")}function jr({pct:t}){const n=t>=85?"bg-rose-400/70":t>=60?"bg-amber-400/70":"bg-emerald-400/70";return e.jsx("span",{className:`h-1.5 w-1.5 rounded-full ${n}`})}function wn(t,n,s){return t==="zh-CN"?n:s}function wr({open:t,onClose:n,workdir:s}){const a=je(d=>d.locale),l=s.split("/").pop()||s;return e.jsxs(_t,{open:t,onClose:n,wide:!0,children:[e.jsx(Pt,{title:wn(a,`${l} — 项目扩展`,`${l} — Project Extensions`),description:wn(a,"仅对当前工作区生效。直接操作项目目录中的 .mcp.json 与 .pikiloop/skills/。","Project-scoped only. Operates directly on .mcp.json and .pikiloop/skills/ in the workspace directory."),onClose:n}),t?e.jsx(ms,{workdir:s}):null]})}let kn=Sn(()=>import("./SessionPanel-C1geSRxw.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9]));function tn(){return kn??=Sn(()=>import("./SessionPanel-C1geSRxw.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9])),kn}const kr=r.lazy(async()=>({default:(await tn()).SessionPanel})),Xt=5,yr=240,Nr=120,Sr=12,Cr=900*1e3,F=(t,n)=>`${t}:${n}`;function Er(t){const n=new Map;for(const c of t)n.set(F(c.agent||"",c.sessionId),c);const s=new Map,a=new Set;for(const c of t){const m=c.migratedFrom;if(!m||m.kind!=="fork"||!m.sessionId)continue;const v=F(m.agent||c.agent||"",m.sessionId);n.has(v)&&(a.add(F(c.agent||"",c.sessionId)),s.has(v)||s.set(v,[]),s.get(v).push(c))}const l=[],d=new Set,p=(c,m)=>{const v=F(c.agent||"",c.sessionId);if(d.has(v))return;d.add(v),l.push(Object.assign({},c,{__forkDepth:m}));const g=s.get(v);if(g)for(const j of g)p(j,m+1)};for(const c of t){const m=F(c.agent||"",c.sessionId);a.has(m)||p(c,0)}for(const c of t)p(c,0);return l}let Lr=0;function Tt(){return`mk-${Date.now().toString(36)}-${(++Lr).toString(36)}`}function Mr(t){return t==="vscode"||t==="cursor"||t==="windsurf"||t==="finder"||t==="default"}function Tr(t,n){const s=String(t||"").toLowerCase();return s.includes("cursor")?"cursor":s.includes("windsurf")?"windsurf":s.includes("code")||n==="darwin"?"vscode":"default"}function Fn(t){switch(t){case"cursor":return"hub.openTargetCursor";case"windsurf":return"hub.openTargetWindsurf";case"finder":return"hub.openTargetFinder";case"default":return"hub.openTargetDefault";default:return"hub.openTargetVsCode"}}const Ir=r.memo(function({active:n=!0}){const s=je(o=>o.locale),a=je(o=>o.state?.runtimeWorkdir??null),l=r.useMemo(()=>as(s),[s]),[d,p]=r.useState([]),[c,m]=r.useState({}),[v,g]=r.useState({}),[j,E]=r.useState(!0),[k,N]=r.useState(()=>{try{const u=sessionStorage.getItem("pikiloop-layout-mode");if(u==="1"||u==="2"||u==="3"||u==="6")return Number(u)}catch{}const o=window.innerWidth;return o>=1920?3:o>=1280?2:1}),[M,A]=r.useState(()=>{try{const o=sessionStorage.getItem("pikiloop-open-sessions");if(o){const u=JSON.parse(o);if(Array.isArray(u))return u.map(h=>({...h,mountKey:h.mountKey||Tt()}))}}catch{}return[]}),[B,O]=r.useState(()=>{try{const o=sessionStorage.getItem("pikiloop-active-slot");if(o!=null){const u=Number(o);if(Number.isFinite(u)&&u>=0)return u}}catch{}return 0}),H=r.useCallback(o=>{N(o);try{sessionStorage.setItem("pikiloop-layout-mode",String(o))}catch{}},[]),_=r.useCallback(o=>{A(u=>{const h=typeof o=="function"?o(u):o;try{const f=h.map(({pendingPrompt:w,pendingImageUrls:y,...C})=>C);sessionStorage.setItem("pikiloop-open-sessions",JSON.stringify(f))}catch{}return h})},[]),I=r.useCallback(o=>{O(u=>{const h=typeof o=="function"?o(u):o;try{sessionStorage.setItem("pikiloop-active-slot",String(h))}catch{}return h})},[]);r.useEffect(()=>{_(o=>o.length>k?o.slice(0,k):o),I(o=>o>=k?k-1:o)},[k]);const[D,K]=r.useState(!1),ae=r.useRef(k);ae.current=k;const Z=r.useRef(B);Z.current=B;const T=r.useRef(-1),V=M[B]??null,Me=r.useCallback(o=>{if(!o){_([]),I(0);return}const u=o.mountKey?o:{...o,mountKey:Tt()};_(h=>{const f=h.findIndex(y=>y.agent===u.agent&&y.sessionId===u.sessionId);if(f>=0)return I(f),h;if(h.length<ae.current){const y=[...h,u];return I(y.length-1),y}const w=[...h];return w[Z.current]=u,w})},[]),[ce,we]=r.useState(!1),[$,Fe]=r.useState(null),[Te,tt]=r.useState(""),[ke,bt]=r.useState("all"),[de,vt]=r.useState({}),ee=r.useDeferredValue(Te),te=r.useRef(!1),Ue=r.useRef({}),Ie=r.useRef(c);Ie.current=c;const ze=r.useRef(de);ze.current=de;const nt=r.useRef(new Set),ne=r.useRef({});r.useEffect(()=>()=>{for(const o of Object.values(ne.current))clearTimeout(o)},[]);const le=r.useCallback(async()=>{try{const o=await J.getWorkspaces(),u=o.ok?o.workspaces:[];u.length&&p(h=>h.length===u.length&&h.every((f,w)=>f.path===u[w].path&&f.name===u[w].name)?h:u),te.current=!0}catch{te.current=!0}finally{E(!1)}},[]);r.useEffect(()=>{le()},[le]);const P=r.useCallback(async(o,u={})=>{if(!Ue.current[o]){Ue.current[o]=!0,u.background||g(h=>({...h,[o]:!0}));try{const h=await ks(o,{force:u.force});r.startTransition(()=>{m(f=>{const w=h.sessions||[],y=f[o]||[],C=new Set(w.map(z=>F(z.agent||"",z.sessionId))),U=y.filter(z=>{if(z.runState!=="running")return!1;const ie=F(z.agent||"",z.sessionId);if(C.has(ie))return!1;const dt=ze.current[ie];return!(dt?.resolvedKey&&dt.resolvedKey!==ie)});return{...f,[o]:U.length?[...U,...w]:w}})})}catch{u.background||r.startTransition(()=>{m(h=>({...h,[o]:[]}))})}finally{Ue.current[o]=!1,u.background||g(h=>({...h,[o]:!1}))}}},[]),ye=r.useRef(a);r.useEffect(()=>{a!==ye.current&&(ye.current=a,!(!a||!te.current)&&le().then(()=>{P(a,{force:!0})}))},[a,le,P]);const X=r.useCallback((o,u)=>{const h=o.agent||"";!h||!o.sessionId||(tn(),Ss({workdir:u,agent:h,sessionId:o.sessionId,rich:!0,turnOffset:0,turnLimit:Sr}))},[]),Ae=r.useCallback((o,u,h=Nr)=>{const f=`${u}:${F(o.agent||"",o.sessionId)}`,w=ne.current[f];w&&clearTimeout(w),ne.current[f]=setTimeout(()=>{delete ne.current[f],X(o,u)},h)},[X]),Re=r.useCallback((o,u)=>{const h=`${u}:${F(o.agent||"",o.sessionId)}`,f=ne.current[h];f&&(clearTimeout(f),delete ne.current[h])},[]);r.useEffect(()=>{n&&tn()},[n]),r.useEffect(()=>{if(!n)return;const o=[];return d.forEach((u,h)=>{if(c[u.path]||v[u.path])return;const f=setTimeout(()=>{P(u.path)},h*90);o.push(f)}),()=>{for(const u of o)clearTimeout(u)}},[n,P,v,c,d]);const jt=r.useRef(new Map);mn(n&&te.current&&d.length>0?"sessions-changed":null,r.useCallback(o=>{if(typeof document<"u"&&document.visibilityState==="hidden")return;const u=o.key,h=u?d.filter(y=>(Ie.current[y.path]||[]).some(C=>F(C.agent||"",C.sessionId)===u)):d,f=h.length?h:d,w=jt.current;for(const y of f)w.has(y.path)&&clearTimeout(w.get(y.path)),w.set(y.path,setTimeout(()=>{w.delete(y.path),P(y.path,{background:!0,force:!0})},300))},[d,P]));const W=r.useCallback(o=>{const u=o.agent||"";return!u||!o.sessionId?o:ls(o,de[F(u,o.sessionId)]||null)},[de]);mn("stream-update",r.useCallback(o=>{const u=o.key;u&&vt(h=>{const f={},w=Date.now()-Cr;for(const[C,U]of Object.entries(h))U.updatedAt>=w&&(f[C]=U);const y=cs(u,o.snapshot??null);if(!y){const C=f[u];return C&&C.phase!=="done"&&(f[u]={...C,phase:"done",updatedAt:Date.now()}),f}return f[u]=y,y.resolvedKey!==u&&(f[y.resolvedKey]={...y,key:y.resolvedKey}),f})},[])),Rs(r.useCallback(()=>{if(!(!n||!te.current||d.length===0))for(const o of d)P(o.path,{background:!0,force:!0})},[n,d,P])),r.useEffect(()=>{if(!n||!te.current||d.length===0)return;const o=()=>{if(!(typeof document<"u"&&document.visibilityState==="hidden"))for(const h of d)P(h.path,{background:!0,force:!0})};if(o(),typeof document>"u"||typeof window>"u")return;const u=()=>{document.visibilityState==="visible"&&o()};return document.addEventListener("visibilitychange",u),window.addEventListener("focus",u),()=>{document.removeEventListener("visibilitychange",u),window.removeEventListener("focus",u)}},[n,P,d]),r.useEffect(()=>{if(!n)return;const o=[];return d.forEach((u,h)=>{const f=(c[u.path]||[])[0];if(!f)return;const w=`${u.path}:${F(f.agent||"",f.sessionId)}`;if(nt.current.has(w))return;const y=setTimeout(()=>{nt.current.add(w),X(f,u.path)},yr+h*120);o.push(y)}),()=>{for(const u of o)clearTimeout(u)}},[n,c,X,d]);const se=r.useCallback(async o=>{try{(await J.addWorkspace(o)).ok&&(we(!1),await le(),P(o))}catch{}},[le,P]),[pe,Ne]=r.useState(null),[re,_e]=r.useState(!1),[st,wt]=r.useState(null),He=r.useCallback(o=>{Ne(o)},[]),rt=r.useCallback(async()=>{const o=pe;if(o){_e(!0);try{await J.removeWorkspace(o),p(u=>u.filter(h=>h.path!==o)),m(u=>{const h={...u};return delete h[o],h}),_(u=>u.filter(h=>h.workdir!==o)),I(0),Ne(null)}catch{}finally{_e(!1)}}},[pe]),ot=r.useCallback(o=>{P(o,{force:!0})},[P]),[Se,G]=r.useState(null),[xe,Ce]=r.useState(!1),[oe,Pe]=r.useState(!1),We=je(o=>o.toast),[ue,it]=r.useState(null),at=r.useCallback((o,u,h)=>{it({anchor:{right:o.right,bottom:o.bottom},target:{workdir:h,agent:u.agent||"",sessionId:u.sessionId,title:yn(u).slice(0,120)||u.sessionId.slice(0,16)}})},[]);r.useEffect(()=>{if(!ue)return;const o=()=>it(null),u=h=>{h.key==="Escape"&&o()};return window.addEventListener("mousedown",o),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),window.addEventListener("keydown",u),()=>{window.removeEventListener("mousedown",o),window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o),window.removeEventListener("keydown",u)}},[ue]);const Bt=r.useCallback(o=>{Ce(!1),G(o),it(null)},[]),kt=r.useCallback(async()=>{const o=Se;if(o){Pe(!0);try{const u=await J.deleteSession(o.workdir,o.agent,o.sessionId,xe);if(!u.ok){const h=u.error?.includes("still running")?l("session.deleteRunningError"):u.error||l("session.deleteFailed");We(h,!1);return}m(h=>{const f=h[o.workdir];if(!f)return h;const w=f.filter(y=>!(y.agent===o.agent&&y.sessionId===o.sessionId));return w.length===f.length?h:{...h,[o.workdir]:w}}),_(h=>h.filter(f=>!(f.workdir===o.workdir&&f.agent===o.agent&&f.sessionId===o.sessionId))),G(null)}catch(u){We(u?.message||l("session.deleteFailed"),!1)}finally{Pe(!1)}}},[Se,xe,l,We]),$t=r.useCallback(o=>{_(u=>{let h=!1;const f=u.map(w=>w.mountKey===o&&(w.pendingPrompt!=null||w.pendingImageUrls)?(h=!0,{...w,pendingPrompt:null,pendingImageUrls:void 0}):w);return h?f:u})},[_]),lt=r.useCallback((o,u,h)=>{X({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),m(y=>{const C=y[o.workdir]||[];if(C.some(ie=>ie.sessionId===o.sessionId&&ie.agent===o.agent))return y;const z={sessionId:o.sessionId,agent:o.agent,runState:"running",lastQuestion:u,createdAt:new Date().toISOString(),runUpdatedAt:new Date().toISOString()};return{...y,[o.workdir]:[z,...C]}});const f=T.current,w={...o,mountKey:Tt(),pendingPrompt:u||null,pendingImageUrls:h&&h.length?h:void 0};r.startTransition(()=>{Fe(null),_(y=>{if(f>=y.length)return[...y,w];const C=[...y];return C[f]=w,C}),I(f>=0?f:0)}),P(o.workdir,{background:!0,force:!0})},[P,X,_,I]),Be=r.useCallback((o,u)=>{X(o,u),Fe(null),r.startTransition(()=>{Me({agent:o.agent||"",sessionId:o.sessionId,workdir:u})})},[X]),Ke=r.useCallback((o,u)=>{X({agent:o.agent,sessionId:o.sessionId,runState:"running"},o.workdir),r.startTransition(()=>{u!=null?(_(h=>{if(u>=h.length)return h;const f=[...h];return f[u]={...h[u],agent:o.agent,sessionId:o.sessionId,workdir:o.workdir},f}),I(u)):Me({...o,mountKey:Tt()})}),P(o.workdir,{background:!0,force:!0})},[P,X]),Ve=r.useCallback(o=>{let u=o;if(ke==="running"?u=u.filter(h=>It(h)==="running"):ke==="review"&&(u=u.filter(h=>It(h)==="incomplete")),ee.trim()){const h=ee.toLowerCase();u=u.filter(f=>(f.lastMessageText||"").toLowerCase().includes(h)||(f.lastQuestion||"").toLowerCase().includes(h)||(f.lastAnswer||"").toLowerCase().includes(h)||(f.title||"").toLowerCase().includes(h)||(f.agent||"").toLowerCase().includes(h))}return u},[ee,ke]),fe=r.useMemo(()=>{const o={};for(const u of d){const h=(c[u.path]||[]).map(W),f=new Map;for(const y of h){const C=F(y.agent||"",y.sessionId),U=de[C],z=U?.resolvedKey&&U.resolvedKey!==C?U.resolvedKey:C,ie=f.get(z);if(!ie){f.set(z,y);continue}F(ie.agent||"",ie.sessionId)!==z&&C===z&&f.set(z,y)}const w=Ve([...f.values()]);o[u.path]=Er(w)}return o},[d,c,de,Ve,W]),yt=r.useCallback(o=>{const u=(c[o.workdir]||[]).find(h=>h.sessionId===o.sessionId&&h.agent===o.agent)??{sessionId:o.sessionId,agent:o.agent,runState:"running"};return W(u)},[W,c]),ct=r.useMemo(()=>new Set(M.map(o=>F(o.agent,o.sessionId))),[M]),Nt=V?F(V.agent,V.sessionId):null,St=r.useCallback(o=>{_(u=>{const h=u.filter((f,w)=>w!==o);return h.length===0?I(0):Z.current>=h.length&&I(h.length-1),h})},[]);return e.jsxs("div",{className:"h-full overflow-hidden p-4 flex gap-3 mx-auto",children:[e.jsxs("div",{className:"panel-isolated w-[252px] shrink-0 flex flex-col overflow-hidden rounded-xl border border-edge bg-panel backdrop-blur-sm",style:{boxShadow:"var(--th-card-shadow)"},children:[e.jsxs("div",{className:"px-3 pt-3 pb-2 space-y-2",children:[e.jsxs("div",{className:"relative group",children:[e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-fg-5/40 group-focus-within:text-fg-4 transition-colors",children:[e.jsx("circle",{cx:"11",cy:"11",r:"8"}),e.jsx("line",{x1:"21",y1:"21",x2:"16.65",y2:"16.65"})]}),e.jsx("input",{value:Te,onChange:o=>tt(o.target.value),placeholder:l("hub.search"),className:"w-full rounded-lg border border-edge/40 bg-inset/50 pl-8 pr-7 py-1.5 text-[12px] text-fg outline-none placeholder:text-fg-5/30 focus:border-primary/30 focus:bg-inset focus:shadow-[0_0_0_3px_rgba(99,102,241,0.06)] transition-all duration-200"}),Te&&e.jsx("button",{onClick:()=>tt(""),className:"absolute right-2 top-1/2 -translate-y-1/2 p-0.5 rounded text-fg-5/30 hover:text-fg-4 transition-colors",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex items-center rounded-lg bg-inset/30 border border-edge/20 p-0.5",children:["all","running","review"].map(o=>e.jsx("button",{onClick:()=>bt(o),className:L("flex-1 px-2 py-[5px] rounded-md text-[11px] font-medium transition-all duration-200",ke===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1),inset_0_1px_0_rgba(255,255,255,0.04)]":"text-fg-5/60 hover:text-fg-4"),children:l(`hub.filter${o[0].toUpperCase()+o.slice(1)}`)},o))})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:j?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(he,{className:"h-4 w-4 text-fg-5"})}):d.length===0&&!ce?e.jsx("div",{className:"py-12 text-center text-[13px] text-fg-5",children:l("hub.noWorkspaces")}):d.map(o=>e.jsx(Pr,{workspace:o,sessions:fe[o.path]||[],loading:!!v[o.path]||!(o.path in c),isActive:o.path===a,selectedKey:Nt,openSessionKeys:ct,onSelectSession:Be,onNewSession:Fe,onRefresh:ot,onRemove:He,onExtensions:wt,onWarmSession:Ae,onCancelWarmSession:Re,onSessionMenuOpen:at,t:l},o.path))}),e.jsxs("div",{className:"shrink-0 border-t border-edge/20 px-3 py-2 space-y-1.5",children:[e.jsx("div",{className:"flex items-center rounded-md bg-inset/30 border border-edge/20 p-0.5",children:[1,2,3,6].map(o=>e.jsx("button",{onClick:()=>H(o),className:L("flex-1 flex items-center justify-center p-1.5 rounded transition-all",k===o?"bg-panel-h text-fg-2 shadow-[0_1px_2px_rgba(0,0,0,0.1)]":"text-fg-5/40 hover:text-fg-4"),title:l(`hub.layout${o}`),children:o===1?e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:e.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"1.5"})}):o===2?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"1",y:"2",width:"6",height:"12",rx:"1.5"}),e.jsx("rect",{x:"9",y:"2",width:"6",height:"12",rx:"1.5"})]}):o===3?e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"0.5",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"6",y:"2",width:"4",height:"12",rx:"1"}),e.jsx("rect",{x:"11.5",y:"2",width:"4",height:"12",rx:"1"})]}):e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.2",children:[e.jsx("rect",{x:"0.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"1",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"0.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"6",y:"9.5",width:"4",height:"5.5",rx:"0.8"}),e.jsx("rect",{x:"11.5",y:"9.5",width:"4",height:"5.5",rx:"0.8"})]})},o))}),e.jsxs(Ee,{variant:"ghost",size:"sm",onClick:()=>we(o=>!o),className:"w-full",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]}),l("hub.addWorkspace")]})]})]}),e.jsx("div",{className:"flex-1 min-w-0 flex flex-col overflow-hidden gap-0",children:e.jsx("div",{className:"flex-1 min-h-0 grid gap-3",style:{gridTemplateColumns:`repeat(${k===6?3:k}, 1fr)`,gridTemplateRows:k===6?"repeat(2, 1fr)":"1fr"},children:(()=>{const o=$?M.length<k?M.length:B:-1;return T.current=o,Array.from({length:k},(u,h)=>{if($&&h===o)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-edge bg-panel flex flex-col",style:{boxShadow:"var(--th-card-shadow)"},children:e.jsx(Rr,{workdir:$,workspaceName:d.find(C=>C.path===$)?.name||$.split("/").pop()||"",onSessionCreated:lt,onClose:()=>Fe(null),t:l},$)},`new-${$}`);const f=M[h]??null;if(!f)return e.jsx("div",{className:"min-w-0 overflow-hidden rounded-xl border border-dashed border-edge/40 bg-panel/30 flex items-center justify-center",children:e.jsxs("div",{className:"text-center px-4",children:[e.jsxs("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",className:"mx-auto text-fg-5/20 mb-2",children:[e.jsx("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2"}),e.jsx("line",{x1:"12",y1:"8",x2:"12",y2:"16"}),e.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]}),e.jsx("div",{className:"text-[12px] text-fg-5/40",children:l("hub.emptySlot")})]})},`empty-${h}`);const w=yt(f),y=h===B;return e.jsxs("div",{className:L("min-w-0 overflow-hidden rounded-xl border bg-panel flex flex-col transition-[border-color,box-shadow] duration-200",y?"border-primary/40 ring-[3px] ring-primary/[0.06]":"border-edge hover:border-edge-h"),style:{boxShadow:y?"var(--th-card-shadow), 0 0 0 1px rgba(14,165,233,0.08)":"var(--th-card-shadow)"},onClick:()=>I(h),children:[e.jsxs("div",{className:L("shrink-0 flex items-center gap-2 px-2.5 h-8 border-b border-edge/30",y?"bg-primary/[0.03]":"bg-panel/60"),children:[(()=>{const C=It(w);return e.jsx(Wt,{variant:C==="running"?"ok":C==="waiting"?"info":C==="incomplete"?"warn":"idle",pulse:C==="running"||C==="waiting"})})(),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-0",children:[e.jsx("span",{className:"shrink-0 text-[10px] font-medium text-fg-5",children:f.workdir.split("/").pop()||f.workdir}),e.jsx("span",{className:"shrink-0 text-fg-6 text-[10px] mx-1",children:"/"}),e.jsx("span",{className:"min-w-0 truncate text-[11px] font-medium text-fg-3",children:w.title||w.lastQuestion?.slice(0,60)||f.sessionId.slice(0,12)})]}),e.jsxs("div",{className:"shrink-0 flex items-center gap-2.5 pl-4 text-[9px] text-fg-5/50 tabular-nums",children:[e.jsx("span",{title:l("hub.created"),children:ds(w.createdAt)}),w.runUpdatedAt&&e.jsx("span",{title:l("hub.updated"),children:Nn(w.runUpdatedAt)}),!!w.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),w.numTurns]}),e.jsx("button",{"data-filetree-toggle":!0,onClick:C=>{C.stopPropagation(),K(U=>!U)},className:L("p-0.5 rounded transition-colors",D?"text-fg-3 bg-panel-h":"text-fg-5/40 hover:text-fg-3 hover:bg-panel-h"),title:l("hub.files"),children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})})}),e.jsx("button",{onClick:C=>{C.stopPropagation(),St(h)},className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 hover:bg-panel-h transition-colors",title:l("hub.closePanel"),children:e.jsxs("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(r.Suspense,{fallback:e.jsx("div",{className:"h-full"}),children:e.jsx(kr,{session:w,workdir:f.workdir,active:n&&y,onSessionChange:C=>Ke(C,h),initialPendingPrompt:f.pendingPrompt??null,initialPendingImageUrls:f.pendingImageUrls,onPendingPromptConsumed:()=>$t(f.mountKey)},f.mountKey)})})]},f.mountKey||F(f.agent,f.sessionId))})})()})}),D&&V&&e.jsx(Br,{workdir:V.workdir,onClose:()=>K(!1),t:l}),e.jsx(Ar,{open:ce,initialPath:a||void 0,onAdd:se,onClose:()=>we(!1),t:l}),e.jsxs(_t,{open:!!pe,onClose:()=>!re&&Ne(null),children:[e.jsx(Pt,{title:l("hub.removeWorkspace"),onClose:()=>!re&&Ne(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:l("modal.confirmRemoveWorkspace")}),e.jsx("div",{className:"mt-1 text-[12px] text-fg-5",children:l("modal.confirmRemoveWorkspaceHint")}),pe&&e.jsx("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 font-mono text-[11px] text-fg-4 break-all",children:pe}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(Ee,{variant:"ghost",onClick:()=>Ne(null),disabled:re,children:l("modal.cancel")}),e.jsx(Ee,{variant:"primary",onClick:rt,disabled:re,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:l(re?"modal.removing":"modal.remove")})]})]}),ue&&(()=>{const u=Math.max(8,Math.min(ue.anchor.right-160,window.innerWidth-160-8)),h=Math.min(ue.anchor.bottom+4,window.innerHeight-60);return e.jsx("div",{className:"fixed z-[60] min-w-[160px] rounded-md border border-edge bg-panel/95 backdrop-blur-md py-1",style:{left:u,top:h,boxShadow:"0 8px 24px rgba(0,0,0,0.20), 0 2px 6px rgba(0,0,0,0.10)"},onMouseDown:f=>f.stopPropagation(),role:"menu",children:e.jsxs("button",{type:"button",role:"menuitem",onClick:()=>Bt(ue.target),className:"w-full flex items-center gap-2 px-3 py-1.5 text-left text-[12px] text-fg-2 hover:bg-panel-h/60 hover:text-red-400 transition-colors",children:[e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("polyline",{points:"3 6 5 6 21 6"}),e.jsx("path",{d:"M19 6l-1 14a2 2 0 01-2 2H8a2 2 0 01-2-2L5 6"}),e.jsx("path",{d:"M10 11v6"}),e.jsx("path",{d:"M14 11v6"}),e.jsx("path",{d:"M9 6V4a2 2 0 012-2h2a2 2 0 012 2v2"})]}),l("session.delete")]})})})(),e.jsxs(_t,{open:!!Se,onClose:()=>!oe&&G(null),children:[e.jsx(Pt,{title:l("session.deleteTitle"),onClose:()=>!oe&&G(null)}),e.jsx("div",{className:"text-[13px] text-fg-3 leading-relaxed",children:l("session.deleteHint")}),Se&&e.jsxs("div",{className:"mt-3 rounded-md bg-inset/50 border border-edge/30 px-3 py-2 text-[11px] text-fg-4 break-all",children:[e.jsx("span",{className:"font-mono text-fg-5",children:Se.agent}),e.jsx("span",{className:"mx-1.5 text-fg-5/50",children:"·"}),e.jsx("span",{children:Se.title})]}),e.jsxs("div",{className:"mt-4 space-y-2",children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:!xe,onChange:()=>Ce(!1),disabled:oe,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:l("session.deletePikiloopOnly")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:l("session.deletePikiloopOnlyHint")})]})]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"delete-session-scope",checked:xe,onChange:()=>Ce(!0),disabled:oe,className:"mt-0.5"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"text-[12px] text-fg-2",children:l("session.deletePurgeNative")}),e.jsx("div",{className:"text-[11px] text-fg-5 leading-snug mt-0.5",children:l("session.deletePurgeNativeHint")})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-2 mt-4",children:[e.jsx(Ee,{variant:"ghost",onClick:()=>G(null),disabled:oe,children:l("modal.cancel")}),e.jsx(Ee,{variant:"primary",onClick:kt,disabled:oe,className:"!bg-red-500/90 !border-red-500/50 hover:!bg-red-500 !text-white",children:l(oe?"session.deleting":"modal.remove")})]})]}),e.jsx(wr,{open:!!st,onClose:()=>wt(null),workdir:st||""})]})});function Ar({open:t,initialPath:n,onAdd:s,onClose:a,t:l}){const[d,p]=r.useState(""),c=r.useCallback(m=>p(m),[]);return r.useEffect(()=>{t&&p("")},[t]),e.jsxs(_t,{open:t,onClose:a,children:[e.jsx(Pt,{title:l("hub.addWorkspace"),onClose:a}),e.jsx(xs,{initialPath:n,maxHeight:360,minHeight:200,onSelect:c,t:l}),e.jsxs("div",{className:"flex gap-2 mt-4",children:[e.jsx(Ee,{disabled:!d,onClick:()=>d&&s(d),className:"flex-1",children:l("hub.add")}),e.jsx(Ee,{variant:"secondary",onClick:a,className:"flex-1",children:l("hub.cancel")})]})]})}function Rr({workdir:t,workspaceName:n,onSessionCreated:s,onClose:a,t:l}){const[d,p]=r.useState(null),[c,m]=r.useState([]),v=r.useRef(null),g=r.useRef([]),j=r.useMemo(()=>({sessionId:"",agent:"",runState:"completed"}),[]),E=r.useCallback(()=>{},[]),k=r.useCallback((A,B)=>{p(A||null),v.current=A||null;const O=B||[];m(O),g.current=O},[]),N=r.useCallback(A=>{const B=g.current;g.current=[],s(A,v.current||void 0,B.length?B:void 0)},[s]),M=!!d||c.length>0;return e.jsxs("div",{className:"flex flex-col h-full overflow-hidden",children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-2 px-4 h-10 border-b border-edge/50 bg-panel/40 backdrop-blur-md z-10",children:[e.jsx("span",{className:"flex-1 min-w-0 text-[13px] font-medium text-fg truncate",children:l("hub.newSession")}),e.jsxs("span",{className:"flex items-center gap-1 text-[10px] text-fg-5/60 shrink-0",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-60",children:e.jsx("path",{d:"M22 19a2 2 0 01-2 2H4a2 2 0 01-2-2V5a2 2 0 012-2h5l2 3h9a2 2 0 012 2z"})}),e.jsx("span",{className:"max-w-[80px] truncate",children:n})]}),e.jsx(Wt,{variant:M?"ok":"idle",pulse:M}),!M&&e.jsx("button",{onClick:a,className:"p-1 rounded text-fg-5 hover:text-fg-2 transition-colors",children:e.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsx("div",{className:"flex-1 overflow-y-auto",children:M?e.jsxs("div",{className:"max-w-[900px] mx-auto px-6 py-6 space-y-0",children:[e.jsx(On,{text:d||"",blocks:c.map(A=>({type:"image",content:A})),t:l}),e.jsx("div",{className:"mt-3 mb-4 animate-in",children:e.jsx(en,{className:"text-fg-5"})})]}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx("div",{className:"text-center space-y-1.5",children:e.jsx("div",{className:"text-[13px] text-fg-5",children:l("hub.newSessionHint")})})})}),e.jsx(Gs,{session:j,workdir:t,onStreamQueued:E,onSendStart:k,onSessionChange:N,t:l,streamPhase:null})]})}function _r({git:t}){if(!t)return null;const n=[t.detached?`detached HEAD${t.shortSha?` @ ${t.shortSha}`:""}`:`branch ${t.branch??"?"}`,t.upstream?`upstream ${t.upstream}`:t.detached?"":"no upstream",t.ahead||t.behind?`↑${t.ahead} ahead · ↓${t.behind} behind`:"",t.changed>0?`${t.changed} changed (${t.staged} staged · ${t.unstaged} unstaged · ${t.untracked} untracked)`:"clean"].filter(Boolean).join(`
|
|
23
|
+
`);return e.jsx(us,{content:n,className:L("shrink-0 items-center",t.changed>0?"text-amber-400/80":t.ahead||t.behind?"text-sky-400/70":"text-fg-5/50"),onClick:s=>s.stopPropagation(),children:e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2.5"}),e.jsx("circle",{cx:"6",cy:"18",r:"2.5"}),e.jsx("circle",{cx:"18",cy:"8",r:"2.5"}),e.jsx("path",{d:"M6 8.5v7"}),e.jsx("path",{d:"M18 10.5c0 4.5-6 3-6 7.5"})]})})}const Pr=r.memo(function({workspace:n,sessions:s,loading:a,isActive:l,selectedKey:d,openSessionKeys:p,onSelectSession:c,onNewSession:m,onRefresh:v,onRemove:g,onExtensions:j,onWarmSession:E,onCancelWarmSession:k,onSessionMenuOpen:N,t:M}){const[A,B]=r.useState(!0),[O,H]=r.useState(Xt);r.useEffect(()=>{H(Xt)},[s.length]);const _=s.slice(0,O),I=s.length-O,D=n.path,[K,ae]=r.useState(null),Z=r.useCallback(()=>{J.getWorkspaceGit(D).then(T=>ae(T.git)).catch(()=>ae(null))},[D]);return r.useEffect(()=>{Z()},[Z]),e.jsxs("div",{className:"border-b border-edge/30",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 cursor-pointer hover:bg-panel-h/50 transition-colors",onClick:()=>B(T=>!T),children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:L("shrink-0 text-fg-5 transition-transform duration-150",A&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-1.5",children:[e.jsx("span",{className:L("min-w-0 truncate text-[12px] font-semibold",l?"text-primary":"text-fg-3"),children:n.name}),e.jsx(_r,{git:K})]}),l&&e.jsx(Wt,{variant:"ok"}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx("button",{onClick:T=>{T.stopPropagation(),m(D)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:M("hub.newSession"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",children:[e.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),e.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}),e.jsx("button",{onClick:T=>{T.stopPropagation(),j(D)},className:"p-1 rounded text-fg-5 hover:text-primary hover:bg-panel-h/60 transition-colors",title:M("hub.extensions"),children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M12 22v-5"}),e.jsx("path",{d:"M9 8V2"}),e.jsx("path",{d:"M15 8V2"}),e.jsx("path",{d:"M18 8v5a6 6 0 0 1-12 0V8z"})]})}),e.jsx("button",{onClick:T=>{T.stopPropagation(),v(D),Z()},className:"p-1 rounded text-fg-5 hover:text-fg-2 hover:bg-panel-h/60 transition-colors",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[e.jsx("polyline",{points:"23 4 23 10 17 10"}),e.jsx("path",{d:"M20.49 15a9 9 0 1 1-2.12-9.36L23 10"})]})}),!l&&e.jsx("button",{onClick:T=>{T.stopPropagation(),g(D)},className:"p-1 rounded text-fg-5 hover:text-red-400 hover:bg-panel-h/60 transition-colors",children:e.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})]}),A&&e.jsx("div",{className:"pb-1",children:a?e.jsx("div",{className:"flex items-center justify-center py-4",children:e.jsx(he,{className:"h-3 w-3 text-fg-5"})}):s.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:M("sessions.noSessions")}):e.jsxs(e.Fragment,{children:[_.map(T=>{const V=F(T.agent||"",T.sessionId),Me=T.__forkDepth||0;return e.jsx(Wr,{session:T,isSelected:d===V,isOpen:p?.has(V)??!1,forkDepth:Me,onClick:()=>c(T,D),onWarm:()=>E(T,D),onCancelWarm:()=>k(T,D),onShowMenu:ce=>N(ce,T,D),menuLabel:M("session.openActions")},V)}),I>0&&e.jsxs("button",{onClick:()=>H(T=>T+Xt),className:"flex items-center gap-1.5 w-full px-3 py-1.5 text-[11px] text-fg-5 hover:text-fg-3 hover:bg-panel-h/50 transition-colors",children:[e.jsxs("span",{children:["+ ",M("hub.nMore").replace("{n}",String(I))]}),e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:e.jsx("polyline",{points:"6 9 12 15 18 9"})})]})]})})]})}),Wr=r.memo(function({session:n,isSelected:s,isOpen:a,forkDepth:l=0,onClick:d,onWarm:p,onCancelWarm:c,onShowMenu:m,menuLabel:v}){const g=Yt(n.agent||""),j=It(n),E=yn(n).slice(0,500)||n.sessionId.slice(0,16),k=hs(n,E).slice(0,500),N=n.model?sn(n.model):null,M=l>0?Math.min(l,3)*14:0,A=a?10:12,B=r.useRef(null);return e.jsxs("div",{className:"relative group",children:[e.jsxs("button",{onClick:d,onMouseEnter:p,onFocus:p,onMouseLeave:c,onBlur:c,className:L("w-full pr-3 py-2 text-left transition-all duration-100",s?"bg-selected hover:bg-selected-h":a?"bg-panel-h/30 hover:bg-panel-h/50":"hover:bg-panel-h/50"),style:{paddingLeft:A+M,...a?{borderLeft:`2px solid ${s?g.color:`${g.color}30`}`}:{}},children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-fg-5",children:[l>0&&e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",className:"text-fg-5/60 shrink-0","aria-label":"Fork",children:[e.jsx("circle",{cx:"6",cy:"6",r:"2"}),e.jsx("circle",{cx:"18",cy:"6",r:"2"}),e.jsx("circle",{cx:"12",cy:"20",r:"2"}),e.jsx("path",{d:"M6 8v3a3 3 0 0 0 3 3h6a3 3 0 0 0 3-3V8"}),e.jsx("path",{d:"M12 14v4"})]}),e.jsx(Xe,{brand:n.agent||"",size:10}),e.jsx("span",{className:"font-medium shrink-0",style:{color:g.color},children:g.shortLabel}),N&&e.jsx("span",{className:"truncate max-w-[72px] font-mono text-fg-5/40 text-[9px]",children:N}),e.jsxs("div",{className:"ml-auto flex items-center gap-1.5 shrink-0 transition-opacity group-hover:opacity-0 group-focus-within:opacity-0",children:[!!n.numTurns&&e.jsxs("span",{className:"flex items-center gap-0.5 text-fg-5/50 tabular-nums",children:[e.jsx("svg",{width:"9",height:"9",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"opacity-50",children:e.jsx("path",{d:"M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"})}),n.numTurns]}),e.jsx("span",{className:"tabular-nums",children:Nn(n.runUpdatedAt||n.createdAt)})]})]}),e.jsxs("div",{className:"mt-1 flex items-center gap-1.5",children:[e.jsx(Wt,{variant:j==="running"?"ok":j==="waiting"?"info":j==="incomplete"?"warn":"idle",pulse:j==="running"||j==="waiting"}),e.jsx("span",{className:"truncate text-[12px] leading-snug text-fg-2",children:E})]}),k&&e.jsx("div",{className:"mt-0.5 pl-[11px]",children:e.jsx("span",{className:"block truncate text-[10px] leading-snug text-fg-5",children:k})})]}),e.jsx("button",{ref:B,type:"button","aria-label":v,"aria-haspopup":"menu",onMouseDown:O=>{O.stopPropagation()},onClick:O=>{O.stopPropagation(),O.preventDefault(),B.current&&m(B.current.getBoundingClientRect())},className:"absolute top-1.5 right-1.5 p-1 rounded text-fg-5 opacity-0 group-hover:opacity-100 focus-visible:opacity-100 hover:bg-panel-h hover:text-fg-2 transition-opacity",children:e.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor","aria-hidden":"true",children:[e.jsx("circle",{cx:"12",cy:"5",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"12",r:"1.5"}),e.jsx("circle",{cx:"12",cy:"19",r:"1.5"})]})})]})}),Br=r.memo(function({workdir:n,onClose:s,t:a}){const l=je(g=>g.state?.hostApp??null),d=je(g=>g.state?.platform??null),p=je(g=>g.toast),[c,m]=r.useState(()=>Tr(l,d)),v=r.useCallback(async g=>{try{const j=await J.openInEditor(g,c);if(!j.ok)throw new Error(j.error||`Failed to open ${g}`)}catch(j){p(j?.message||String(j),!1)}},[c,p]);return e.jsxs("div",{className:"fixed z-50 w-[280px] max-h-[calc(100vh-100px)] flex flex-col rounded-xl border border-edge bg-panel/95 backdrop-blur-md overflow-hidden",style:{boxShadow:"0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12)",right:16,top:80},children:[e.jsxs("div",{className:"shrink-0 flex items-center gap-1.5 px-2.5 py-1.5 border-b border-edge/30",children:[e.jsx("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",className:"shrink-0 text-fg-5",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z"})}),e.jsx("span",{className:"flex-1 text-[10px] font-semibold text-fg-4 uppercase tracking-wider",children:a("hub.files")}),e.jsx("button",{onClick:s,className:"p-0.5 rounded text-fg-5/40 hover:text-fg-2 transition-colors",title:a("hub.closePanel"),children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:"shrink-0 px-2.5 py-1.5 border-b border-edge/20 flex items-center gap-2",children:[e.jsx(ps,{value:c,options:(d==="darwin"?["vscode","finder"]:["vscode"]).map(g=>({value:g,label:a(Fn(g))})),onChange:g=>{Mr(g)&&m(g)},renderIcon:g=>e.jsx(Un,{target:g,size:14})}),e.jsx(Ee,{size:"sm",variant:"ghost",onClick:()=>v(n),className:"flex-1 min-w-0 text-[11px]",children:a("hub.openProject")})]}),e.jsx("div",{className:"flex-1 overflow-y-auto px-1 py-1.5",children:e.jsx($r,{basePath:n,openTarget:c,onOpenPath:v,t:a})})]})});function Un({target:t,size:n=16}){return t==="default"?e.jsxs("svg",{width:n,height:n,viewBox:"0 0 16 16",className:"shrink-0 text-fg-4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("path",{d:"M6 3H4a1 1 0 0 0-1 1v8a1 1 0 0 0 1 1h8a1 1 0 0 0 1-1v-2"}),e.jsx("path",{d:"M9 2h5v5"}),e.jsx("path",{d:"M14 2L7 9"})]}):e.jsx(Xe,{brand:t,size:n})}function $r({basePath:t,includeHidden:n=!1,openTarget:s,onOpenPath:a,t:l}){const[d,p]=r.useState([]),[c,m]=r.useState(!0);r.useEffect(()=>{let g=!1;return m(!0),J.lsDir(t,!0,n).then(j=>{!g&&j.ok&&p(j.dirs.slice(0,50).map(E=>({entry:E,expanded:!1,children:null,loading:!1})))}).catch(()=>{}).finally(()=>{g||m(!1)}),()=>{g=!0}},[t,n]);const v=r.useCallback(g=>{const j=E=>E.map(k=>k.entry.path===g?k.expanded?{...k,expanded:!1}:k.children===null?(J.lsDir(g,!0,n).then(N=>{N.ok&&p(M=>nn(M,g,{children:N.dirs.slice(0,50).map(A=>({entry:A,expanded:!1,children:null,loading:!1})),loading:!1}))}).catch(()=>{p(N=>nn(N,g,{children:[],loading:!1}))}),{...k,loading:!0,expanded:!0}):{...k,expanded:!0}:k.children?{...k,children:j(k.children)}:k);p(E=>j(E))},[n]);return c?e.jsx("div",{className:"flex justify-center py-3",children:e.jsx(he,{className:"h-3 w-3 text-fg-5"})}):d.length===0?e.jsx("div",{className:"py-3 text-center text-[11px] text-fg-5",children:"—"}):e.jsx("div",{className:"space-y-px",children:e.jsx(zn,{nodes:d,depth:0,onToggle:v,openTarget:s,onOpenPath:a,t:l})})}function zn({nodes:t,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:d}){return e.jsx(e.Fragment,{children:t.map(p=>e.jsx(Or,{node:p,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:d},p.entry.path))})}function Or({node:t,depth:n,onToggle:s,openTarget:a,onOpenPath:l,t:d}){const{entry:p,expanded:c,children:m,loading:v}=t,g=n*14,[j,E]=r.useState(!1),k=d(Fn(a)),N=d("hub.openWithTarget").replace("{target}",k);return e.jsxs(e.Fragment,{children:[e.jsxs("div",{onClick:p.isDir?()=>s(p.path):void 0,onMouseEnter:()=>E(!0),onMouseLeave:()=>E(!1),className:L("flex items-center gap-1.5 py-1 rounded text-[11px] text-fg-3 transition-colors",p.isDir?"hover:bg-panel-h/50 cursor-pointer":"hover:bg-panel-h/50 cursor-default"),style:{paddingLeft:8+g,paddingRight:8},children:[p.isDir?v?e.jsx(he,{className:"h-2 w-2 text-fg-5 shrink-0"}):e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",className:L("shrink-0 text-fg-5/40 transition-transform duration-150",c&&"rotate-90"),children:e.jsx("polyline",{points:"9 6 15 12 9 18"})}):e.jsx("span",{className:"w-2 shrink-0"}),p.isDir?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",className:"shrink-0 text-blue-400/70",children:e.jsx("path",{d:"M2 6a2 2 0 012-2h5l2 2h9a2 2 0 012 2v10a2 2 0 01-2 2H4a2 2 0 01-2-2V6z",fill:"currentColor",opacity:"0.25",stroke:"currentColor",strokeWidth:"1.5"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",className:"shrink-0 text-fg-5",children:[e.jsx("path",{d:"M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z"}),e.jsx("polyline",{points:"14 2 14 8 20 8"})]}),e.jsx("span",{className:"truncate flex-1",children:p.name}),j&&e.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e.jsx("button",{onClick:M=>{M.stopPropagation(),l(p.path)},className:"inline-flex items-center gap-1 rounded px-1 py-0.5 text-fg-5 hover:text-blue-400 transition-colors",title:N,children:e.jsx(Un,{target:a,subtle:!0})}),!p.isDir&&e.jsx(Dr,{filePath:p.path,t:d})]})]}),p.isDir&&c&&m&&m.length>0&&e.jsx(zn,{nodes:m,depth:n+1,onToggle:s,openTarget:a,onOpenPath:l,t:d})]})}function Dr({filePath:t,t:n}){const[s,a]=r.useState(!1);return e.jsx("button",{onClick:l=>{l.stopPropagation(),navigator.clipboard.writeText(t).then(()=>{a(!0),setTimeout(()=>a(!1),1500)}).catch(()=>{})},className:L("p-0.5 rounded transition-colors",s?"text-ok":"text-fg-5 hover:text-fg-3"),title:n("hub.copied"),children:s?e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:e.jsx("polyline",{points:"20 6 9 17 4 12"})}):e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[e.jsx("rect",{x:"9",y:"9",width:"13",height:"13",rx:"2"}),e.jsx("path",{d:"M5 15H4a2 2 0 01-2-2V4a2 2 0 012-2h9a2 2 0 012 2v1"})]})})}function nn(t,n,s){return t.map(a=>a.entry.path===n?{...a,...s}:a.children?{...a,children:nn(a.children,n,s)}:a)}const to=Object.freeze(Object.defineProperty({__proto__:null,SessionWorkspace:Ir},Symbol.toStringTag,{value:"Module"}));export{Gs as I,Zr as L,tr as R,eo as T,On as U,Jr as a,Pn as b,Rs as c,en as d,Yr as e,fr as f,to as i,Ns as l,Xr as m,Qr as n,ys as p,mn as u};
|