@teammy/server 0.2.13 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/README.md +4 -4
  2. package/dist/main.js +2662 -1505
  3. package/dist/web/assets/Assistant-CEmXtN1H.js +1 -0
  4. package/dist/web/assets/Computers-B-8vIzy-.css +1 -0
  5. package/dist/web/assets/Computers-ChyEKWzc.js +12 -0
  6. package/dist/web/assets/Conversation-CH2XJkku.css +1 -0
  7. package/dist/web/assets/{Conversation-Co9JjVu_.js → Conversation-CSGUsjrV.js} +1 -1
  8. package/dist/web/assets/Dashboard-BEZRdw_R.js +1 -0
  9. package/dist/web/assets/Dashboard-CppFmr8a.css +1 -0
  10. package/dist/web/assets/Dropdown-D625ln2m.js +55 -0
  11. package/dist/web/assets/Files-DywD1EaD.js +1 -0
  12. package/dist/web/assets/{Help-B2IpMg05.js → Help-DgEMyoMA.js} +53 -39
  13. package/dist/web/assets/{Help-BJ0x9N-8.css → Help-jzk8aJGg.css} +1 -1
  14. package/dist/web/assets/Markdown-Cw4CQNYb.js +29 -0
  15. package/dist/web/assets/MessageComposer-B8Oa9gpY.js +1 -0
  16. package/dist/web/assets/ResourceLibrary-C28WAP-Z.js +6 -0
  17. package/dist/web/assets/ResourceLibrary-uv9-Q5f-.css +1 -0
  18. package/dist/web/assets/TerminalPane-DDJO3cDO.js +22 -0
  19. package/dist/web/assets/WorkspaceTree-BHdUglYr.js +1 -0
  20. package/dist/web/assets/file-links-CVbLZSaw.js +1 -0
  21. package/dist/web/assets/index-DjMoKD7A.js +10 -0
  22. package/dist/web/assets/index-u6KD7Soy.css +1 -0
  23. package/dist/web/assets/project-links-DI2fBvjw.js +1 -0
  24. package/dist/web/assets/{workflow-DM6NUqoB.svg → workflow-h92qCEHO.svg} +1 -1
  25. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  26. package/dist/web/downloads/teammy-skill.zip +0 -0
  27. package/dist/web/index.html +3 -3
  28. package/package.json +1 -1
  29. package/dist/web/assets/Assistant-ysfCwRha.js +0 -1
  30. package/dist/web/assets/Computers-B6RBtpNC.css +0 -1
  31. package/dist/web/assets/Computers-ChbQnbXv.js +0 -7
  32. package/dist/web/assets/Conversation-DKhKiqFy.css +0 -1
  33. package/dist/web/assets/Dashboard-BOsfWF4x.js +0 -1
  34. package/dist/web/assets/Dashboard-J2mog3Rs.css +0 -1
  35. package/dist/web/assets/Dropdown-nwEutrew.js +0 -55
  36. package/dist/web/assets/Files-BQBS447m.js +0 -1
  37. package/dist/web/assets/HtmlPreview-CuQjPwY9.js +0 -1
  38. package/dist/web/assets/Markdown-CE06iKkt.js +0 -29
  39. package/dist/web/assets/MessageComposer--n424osS.js +0 -1
  40. package/dist/web/assets/ResourceLibrary-CxfQ7WWY.css +0 -1
  41. package/dist/web/assets/ResourceLibrary-DgcocHeS.js +0 -6
  42. package/dist/web/assets/TerminalPane-DCgjBDv7.js +0 -22
  43. package/dist/web/assets/WorkspaceTree-BV7twy0b.js +0 -1
  44. package/dist/web/assets/file-links-BiCe1fX2.js +0 -1
  45. package/dist/web/assets/index-DDxaaPSE.js +0 -10
  46. package/dist/web/assets/index-Du6eplBD.css +0 -1
  47. package/dist/web/assets/project-links-Dy6-B89_.js +0 -1
@@ -0,0 +1 @@
1
+ import{A as e,C as t,E as n,St as r,T as i,_t as a,c as o,ct as s,d as c,dt as l,ft as u,ht as d,k as f,l as p,p as m,pt as h,st as g,u as ee,w as te,x as ne,xt as _}from"./Dropdown-D625ln2m.js";import{A as re,D as ie,E as ae,F as v,M as oe,O as se,R as ce,T as y,i as le,k as b,w as ue}from"./index-DjMoKD7A.js";import{t as de}from"./Markdown-Cw4CQNYb.js";import{i as fe,n as pe,r as me,t as he}from"./Conversation-CSGUsjrV.js";import{t as ge}from"./MessageComposer-B8Oa9gpY.js";var x=_(),S=i(),_e=h({topics:g(h({id:d(),title:d(),summary:d(),author:d(),replies:u(),unread:s(),createdAt:d(),updatedAt:d(),delivery:h({available:s(),connected:s(),state:d(),error:d().nullable()})}))}),ve=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),C=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function w({me:i,mode:u=`messages`}){let{projectId:g,request:_}=ce(),w=te(),be=t(g,i,`${u}-selection`),T=t(g,i,`${u}-drafts`),xe=(0,x.useCallback)(e=>_(`agents/outbox`,se,{signal:e}),[_]),E=ne(xe,3e3,t(g,i,`outbox`)),Se=(0,x.useCallback)(async e=>u===`messages`?_(`agents/chats`,ue,{signal:e}):{chats:(await _(`channels/topics`,_e,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[_,u]),D=ne(Se,3e3,t(g,i,u,`chats`)),[O,Ce]=(0,x.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??w?.get(be)??``}),k=O.startsWith(`chat:`)?O.slice(5):``,A=!O||!!k,[j,M]=(0,x.useState)(()=>w?.get(t(g,i,`chat`,k))),N=j?.id===k?j:w?.get(t(g,i,`chat`,k)),P=D.data?.chats.find(e=>e.id===k),F=P&&`delivery`in P?P.delivery:void 0,[we,I]=(0,x.useState)(),[L,R]=(0,x.useState)(()=>w?.get(T)??{}),Te=L[O]??``,Ee=e=>R(t=>({...t,[O]:e})),[z,B]=(0,x.useState)(!1),[V,De]=(0,x.useState)(!1),[Oe,ke]=(0,x.useState)(!1),[Ae,H]=(0,x.useState)(!1),[U,je]=(0,x.useState)(``),[Me,Ne]=(0,x.useState)(``),Pe=(0,x.useRef)(e()),[Fe,W]=(0,x.useState)(``),[Ie,G]=(0,x.useState)(``),K=(0,x.useRef)(new Map),Le=(0,x.useRef)(null),q=(0,x.useRef)(!0),J=(0,x.useRef)(O);J.current=O,(0,x.useEffect)(()=>{j&&w?.set(t(g,i,`chat`,j.id),j)},[w,g,i,j]),(0,x.useEffect)(()=>{w?.set(T,L)},[w,T,L]);function Y(e){J.current=e,Ce(e),w?.set(be,e);let t=new URL(location.href);e.startsWith(`chat:`)?t.searchParams.set(`chat`,e.slice(5)):t.searchParams.delete(`chat`),e&&!e.startsWith(`chat:`)&&e!==`debug`?t.searchParams.set(`message`,e):t.searchParams.delete(`message`),history.replaceState(history.state,``,t)}(0,x.useEffect)(()=>{!O&&D.data?.chats.length&&Y(`chat:${D.data.chats[0].id}`)},[O,D.data]);let X=(E.data?.messages??[]).filter(e=>u===`messages`&&e.box===`debug`).reverse(),Z=E.data?.messages.find(e=>e.id===(O===`debug`?we:O));(0,x.useEffect)(()=>{O!==`debug`&&Z?.conversationId&&Y(`chat:${Z.conversationId}`)},[O,Z?.conversationId]);let Q=X.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,x.useEffect)(()=>{Z&&!Z.readAt&&O!==`debug`&&_(`agents/outbox/${Z.id}/read`,b,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(f(e)))},[Z?.id,Z?.readAt,O,_,E.reload]),(0,x.useEffect)(()=>{O===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>_(`agents/outbox/${e}/read`,b,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(f(e)))},[O,Q,_,E.reload]),(0,x.useEffect)(()=>{if(G(``),!k)return;let e=!0,a=-1,o=!1,s=new AbortController,c=t=>{!e||t.id!==k||t.cursor<a||(a=t.cursor,o=!0,t.redirect?Y(`chat:${t.redirect}`):t.entry===`channel`&&u!==`channels`?location.replace(r(`/projects/${g}/channels?chat=${t.id}`)):(M(t),G(``)))};_(`agents/chats/${k}`,y,{signal:s.signal}).then(c).catch(r=>{e&&!s.signal.aborted&&(r instanceof n&&[401,403,404].includes(r.status)&&(w?.delete(t(g,i,`chat`,k)),M(e=>e?.id===k?void 0:e)),o||G(f(r)))});let l=t=>{let n=Number(t.lastEventId);return!e||!Number.isSafeInteger(n)||n<=a?!1:(a=n,!0)},p=new EventSource(r(`/api/v1/projects/${encodeURIComponent(g)}/agents/chats/${encodeURIComponent(k)}/events`));p.addEventListener(`snapshot`,t=>{if(e)try{c(y.parse(JSON.parse(t.data)))}catch(e){G(f(e))}}),p.onerror=()=>{e&&G(`对话连接中断,正在重新连接…`)},p.addEventListener(`context`,e=>{if(!l(e))return;let t=y.pick({kind:!0,title:!0,status:!0,visibility:!0,participants:!0,pending:!0,hold:!0,redirect:!0}).parse(JSON.parse(e.data));t.redirect?Y(`chat:${t.redirect}`):M(e=>e?.id===k?{...e,...t,cursor:a}:e)}),p.addEventListener(`message`,e=>{if(!l(e))return;let t=ae.parse(JSON.parse(e.data));M(n=>n?.id===k?{...n,readCursor:Math.max(n.readCursor,t.seq),cursor:Math.max(n.cursor,Number(e.lastEventId)||0),messages:[...n.messages.filter(e=>e.id!==t.id),t].sort((e,t)=>e.seq-t.seq)}:n)}),p.addEventListener(`message_removed`,e=>{if(!l(e))return;let{id:t}=h({id:d()}).parse(JSON.parse(e.data));M(e=>e?.id===k?{...e,cursor:a,messages:e.messages.filter(e=>e.id!==t)}:e)}),p.addEventListener(`run`,e=>{if(!l(e))return;let t=ie.parse(JSON.parse(e.data));M(n=>n?.id===k?{...n,cursor:Math.max(n.cursor,Number(e.lastEventId)||0),runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n)});for(let e of[`delta`,`reset`,`state`])p.addEventListener(e,t=>{if(!l(t))return;let n=JSON.parse(t.data);M(r=>r?.id===k?{...r,cursor:Math.max(r.cursor,Number(t.lastEventId)||0),messages:r.messages.map(t=>t.runId!==n.id||t.role!==`assistant`?t:{...t,body:e===`delta`?t.body+(n.text??``):e===`reset`?``:n.answer??t.body,state:n.state??t.state}),runs:r.runs.map(t=>t.id===n.id?{...t,answer:e===`delta`?t.answer+(n.text??``):e===`reset`?``:n.answer??t.answer,state:n.state??t.state,error:n.error===void 0?t.error:n.error}:t)}:r)});return()=>{e=!1,s.abort(),p.close()}},[g,k,i,_,w]),(0,x.useEffect)(()=>{if(!N||N.id!==k)return;let e=()=>{document.visibilityState===`visible`&&_(`agents/chats/${k}/read`,h({ok:s()}),{method:`POST`,body:{cursor:N.readCursor}}).then(()=>{D.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>W(f(e)))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[k,N?.readCursor,N?.kind,_]),(0,x.useEffect)(()=>{q.current&&Le.current?.scrollIntoView({block:`end`})},[O,j?.messages,Z?.recipients,X.length]);function Re(){window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}async function $(e){if(q.current=!0,Y(e),W(``),I(void 0),e.startsWith(`chat:`)||e===`debug`)return;let t=E.data?.messages.find(t=>t.id===e)?.conversationId;if(t)Y(`chat:${t}`);else try{await _(`agents/outbox/${e}/read`,b,{method:`POST`}),Re()}catch(e){W(f(e))}}async function ze(){if(!V){De(!0),W(``);try{let e=await _(`agents/chats`,y,{method:`POST`});M(e),await $(`chat:${e.id}`),D.reload()}catch(e){W(f(e))}finally{De(!1)}}}async function Be(t){t.preventDefault();let n=Te.trim();if(!n||z||V)return;B(!0),W(``);let r=K.current.get(O);r&&r.text===n||(r={text:n,id:e()},K.current.set(O,r));try{if(A){let e=r.target??k;if(!e){let t=await _(`agents/chats`,y,{method:`POST`});e=t.id,r.target=e,K.current.set(`chat:${e}`,r),R(t=>({...t,[`chat:${e}`]:n})),J.current===O&&(M(t),Y(`chat:${e}`))}let t=await _(`agents/chats/${e}`,ie.extend({conversationId:d().optional()}),{method:`POST`,body:{text:n,requestId:r.id}});t.conversationId&&t.conversationId!==e&&(J.current===O||J.current===`chat:${e}`)&&Y(`chat:${t.conversationId}`),M(n=>n?.id===e?{...n,runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n),D.reload()}else{let e=await _(`agents/outbox/${Z.id}/reply`,h({conversationId:d()}),{method:`POST`,body:{body:n,requestId:r.id}});Re(),J.current===O&&Y(`chat:${e.conversationId}`),D.reload(),I(void 0)}K.current.delete(O),r.target&&K.current.delete(`chat:${r.target}`),R(e=>({...e,[O]:``,...r.target?{[`chat:${r.target}`]:``}:{}}))}catch(e){W(f(e))}finally{B(!1)}}let Ve=u===`channels`?me:he,He=A&&!N?.closed&&(u!==`channels`||!!k)||!!Z&&!Z.archivedAt,Ue=A&&!N&&(!!k||!D.data);return(0,S.jsxs)(pe,{className:u===`channels`?`channel-layout`:``,testId:`assistant-page`,label:A?`Tim对话`:`消息内容`,navigation:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(oe,{title:u===`channels`?`频道`:`对话`,children:(0,S.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,S.jsx)(p,{className:`assistant-new-chat`,icon:`clear`,label:`清除未读`,disabled:Oe,onClick:()=>{ke(!0),W(``),_(`communication/read`,h({ok:l(!0)}),{method:`POST`,body:{scope:u}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([D.reload(),E.reload()])}).catch(e=>W(f(e))).finally(()=>ke(!1))}}),(0,S.jsx)(p,{className:`assistant-new-chat`,icon:`plus`,label:u===`channels`?`发表话题`:`新建对话`,disabled:V,onClick:()=>u===`channels`?H(!0):void ze(),"data-testid":`assistant-launcher`})]})}),(0,S.jsxs)(`div`,{className:`assistant-message-scroll`,children:[D.loading&&!D.data&&(0,S.jsx)(`p`,{className:`assistant-list-status`,role:`status`,children:`加载中…`}),D.data?.chats.map(e=>(0,S.jsxs)(`button`,{type:`button`,"data-testid":`assistant-chat-${e.id}`,className:`assistant-message-item assistant-chat-item ${k===e.id?`selected`:``}`,"aria-pressed":k===e.id,onClick:()=>void $(`chat:${e.id}`),children:[(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:k===e.id,children:(0,S.jsx)(`strong`,{children:e.title})}),u===`channels`&&`summary`in e&&(0,S.jsx)(`span`,{className:`topic-preview`,children:C(String(e.summary)).slice(0,140)}),(0,S.jsxs)(`time`,{dateTime:e.updatedAt,children:[new Date(e.updatedAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ve(e.updatedAt)]})]}),(0,S.jsx)(`span`,{className:`assistant-message-dot ${e.unread||u!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`})]},e.id)),!!X.length&&(0,S.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${O===`debug`?`selected`:``}`,onClick:()=>void $(`debug`),children:[(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:O===`debug`,children:(0,S.jsx)(`strong`,{children:`运行提醒`})}),(0,S.jsx)(`span`,{children:C(X.at(-1).body)})]}),(0,S.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`})]}),E.data?.messages.filter(e=>u===`messages`&&e.box!==`debug`&&!e.conversationId).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,S.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${O===e.id?`selected`:``}`,onClick:()=>void $(e.id),children:[(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:O===e.id,children:(0,S.jsx)(`strong`,{children:C(e.body)})}),(0,S.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ve(e.createdAt)]})]}),(0,S.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`})]},e.id))]}),(0,S.jsx)(m,{error:!0,children:E.error||D.error})]}),children:[Ae&&(0,S.jsxs)(c,{id:`new-topic`,title:`发表话题`,onClose:()=>H(!1),children:[(0,S.jsx)(ge,{inset:!0,plain:!0,value:Me,onChange:Ne,label:`正文`,placeholder:`开始一个话题…`,sendLabel:`发表话题`,sendDisabled:z||!U.trim(),heading:(0,S.jsx)(`input`,{className:`topic-title`,"aria-label":`标题`,placeholder:`标题`,required:!0,value:U,onChange:e=>je(e.target.value)}),onSubmit:t=>{t.preventDefault(),B(!0),W(``),_(`channels/topics`,y,{method:`POST`,body:{id:Pe.current,title:U,body:Me}}).then(t=>{M(t),Y(`chat:${t.id}`),H(!1),je(``),Ne(``),Pe.current=e(),D.reload()}).catch(e=>W(f(e))).finally(()=>B(!1))}}),(0,S.jsx)(m,{error:!0,children:Fe})]}),(0,S.jsx)(re,{title:(0,S.jsx)(`h2`,{children:A?P?.title??N?.title??(k?`无标题`:`Tim`):O===`debug`?`运行提醒`:`项目消息`}),actions:(0,S.jsxs)(S.Fragment,{children:[u===`channels`&&k&&(0,S.jsx)(le,{conversation:k}),u!==`channels`&&N?.kind===`matter`&&(0,S.jsxs)(`span`,{className:`assistant-participants`,title:N.participants?.join(`、`),children:[N.visibility===`project`?`项目共享 · `:``,N.participants?.join(`、`)]}),u===`channels`&&F?.available&&(F.state===`web`||F.state===`cancelled`||!F.connected)&&(0,S.jsx)(p,{icon:`send`,label:`发布到企业微信频道`,disabled:z,onClick:()=>{B(!0),_(`channels/topics/${k}/publish`,a(),{method:`POST`}).then(()=>D.reload()).catch(e=>W(f(e))).finally(()=>B(!1))}})]})}),u===`channels`&&(0,S.jsx)(m,{error:!0,children:F?.error}),u!==`channels`&&N?.kind===`matter`&&(N.hold||N.pending||N.status===`completed`)&&(0,S.jsx)(`div`,{className:`assistant-matter-state`,role:`status`,children:N.hold?`${N.hold.scope===`all`?`已暂停`:`暂缓修改`} · ${N.hold.reason}`:N.pending?`待确认 · ${N.pending.members.join(`、`)}:${N.pending.question}`:`已完成`}),(0,S.jsxs)(fe,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;q.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[A?Ue?(0,S.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,S.jsx)(ee,{}),(0,S.jsx)(`p`,{role:`status`,children:Ie||D.error?`暂时无法加载对话`:`加载中…`})]}):N?.messages.length?N.messages.filter(e=>e.body||[`queued`,`running`,`failed`].includes(e.state)).map(e=>(0,S.jsx)(`div`,{className:`assistant-turn`,children:(0,S.jsxs)(Ve,{mine:e.role===`user`&&e.author===i,author:`${e.role===`assistant`?`Tim`:e.author}${e.source===`wecom`?` · 企业微信`:``}`,time:e.createdAt,children:[e.body&&(0,S.jsx)(`div`,{className:`markdown`,children:(0,S.jsx)(de,{children:e.body})}),e.role===`assistant`&&[`queued`,`running`].includes(e.state)&&(0,S.jsxs)(`span`,{className:`assistant-typing`,"aria-label":`正在回答`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),e.state===`failed`&&(0,S.jsx)(m,{error:!0,children:N.runs.find(t=>t.id===e.runId)?.error||`本次回答未完成。`})]})},e.id)):(0,S.jsxs)(`div`,{className:`assistant-empty`,children:[(0,S.jsx)(ee,{}),(0,S.jsx)(`p`,{children:`有什么项目问题想聊聊?`})]}):!E.data&&E.loading?(0,S.jsx)(`div`,{className:`assistant-empty`,children:(0,S.jsx)(`p`,{role:`status`,children:`加载中…`})}):O===`debug`?X.map(e=>(0,S.jsx)(ye,{item:e,onReply:e.archivedAt?void 0:()=>{I(e.id),Ee(``),W(``)}},e.id)):Z&&(0,S.jsx)(ye,{item:Z}),(0,S.jsx)(`div`,{ref:Le})]}),(0,S.jsx)(m,{error:!0,children:Fe||(A?Ie:``)}),He?(0,S.jsx)(ge,{value:Te,onChange:Ee,onSubmit:e=>void Be(e),disabled:V,sendDisabled:z||Ue,label:A?`向Tim提问`:`回复消息`}):O!==`debug`&&Z&&(0,S.jsxs)(`div`,{className:`assistant-archived`,children:[(0,S.jsx)(o,{name:`archive`}),`已归档`]})]})}function ye({item:e,onReply:t}){return(0,S.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,S.jsxs)(he,{author:e.box===`debug`?`运行提醒`:`Tim`,time:e.createdAt,children:[(0,S.jsx)(`div`,{className:`markdown`,children:(0,S.jsx)(de,{children:e.body})}),t&&(0,S.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:`回复`})]})})}export{w as Assistant};
@@ -0,0 +1 @@
1
+ .combobox-field{position:relative}.combobox-field input{text-overflow:ellipsis;padding-right:44px}.combobox-field .icon-button{color:var(--color-muted);position:absolute;top:50%;right:6px;transform:translateY(-50%)}.combobox-popup{z-index:10;border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);box-shadow:var(--shadow-menu);flex-direction:column;padding:5px;display:flex;position:fixed}.combobox-popup [role=listbox]{min-height:0;overflow:auto}button.combobox-option{border-radius:var(--radius-sm);text-align:left;border:0;gap:12px;width:100%;min-height:42px;padding:8px 10px;font-weight:400}.combobox-option.active,.combobox-option[aria-selected=true]{background:var(--color-hover)}.combobox-option-copy{flex-direction:column;flex:1;min-width:0;display:flex}.combobox-option-copy>*{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.combobox-option-copy small,.combobox-option-detail,.combobox-message{color:var(--color-muted);font-size:var(--text-xs)}.combobox-option-detail{flex-shrink:0}.combobox-message{margin:0;padding:10px}.combobox-footer{justify-content:flex-end;align-items:center;gap:8px;padding:4px 4px 0;display:flex}.native-history{flex-direction:column;gap:20px;display:flex}.native-history-input-row{align-items:center;gap:10px;display:flex}.native-history>small{font-size:var(--text-xs)}button.native-history-more{min-height:30px;font-size:var(--text-xs);color:var(--color-muted);border:0;padding:3px 8px}.native-history-input-row .combobox{flex:1;min-width:0}.session-images{flex-wrap:wrap;gap:8px;padding:6px 0;display:flex}.session-image{width:112px;position:relative}.session-image-preview{border:1px solid var(--color-line);background:var(--color-soft);width:112px;height:88px;color:var(--color-muted);border-radius:8px;place-items:center;padding:0;display:grid;overflow:hidden}.session-image-preview img{object-fit:cover;width:100%;height:100%;display:block}.session-image-remove,.session-image-status{background:var(--color-surface);width:24px;height:24px;min-height:24px;color:var(--color-muted);border:0;border-radius:50%;place-items:center;padding:3px;display:grid;position:absolute}.session-image-remove{top:4px;right:4px}.session-image-status{top:60px;left:4px}.session-image-status[role=status] .icon{animation:1.2s linear infinite image-upload-spin}@keyframes image-upload-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.session-image-status[role=status] .icon{animation:none}}.session-image-error{color:var(--color-muted);font-size:var(--text-xs);overflow-wrap:anywhere;padding-top:4px;display:block}.session-image-file{display:none}.composer-attachments{flex-shrink:0}.composer-menu.composer-attachments .dropdown-trigger{background:0 0;border-radius:50%;width:32px;height:32px;padding:7px}.composer-menu.composer-attachments .dropdown-menu{width:180px}.composer-menu.composer-attachments .dropdown-menu [role=menuitem]{justify-content:flex-start;gap:8px}#session-image-lightbox{width:min(1100px,94vw);max-width:94vw}#session-image-lightbox .dialog-header{margin-bottom:var(--space-3);gap:4px}#session-image-lightbox .dialog-header h2{text-overflow:ellipsis;white-space:nowrap;min-width:0;font-size:var(--text-sm);flex:1;overflow:hidden}.session-image-viewer{outline:none;min-width:0}.file-preview-text,.file-preview-document,.session-image-viewer .html-preview{max-height:70dvh;overflow:auto}.file-preview-document,.session-image-viewer .html-preview{border:0;width:100%;height:70dvh}.file-preview-text{padding:8px}.file-preview-text .raw{white-space:pre-wrap;overflow-wrap:anywhere}.file-preview-text mark{background:var(--color-soft);color:inherit;outline:1px solid var(--color-line)}.file-preview-empty{color:var(--color-muted);text-align:center;padding:32px 0}.computer-file-link,.markdown .computer-file-link{min-height:0;color:inherit;font:inherit;text-align:inherit;text-decoration:underline;-webkit-text-decoration-color:var(--color-muted);text-decoration-color:var(--color-muted);text-underline-offset:3px;overflow-wrap:anywhere;cursor:pointer;background:0 0;border:0;border-radius:0;padding:0;display:inline}#session-image-lightbox .dialog-header small{white-space:nowrap;color:var(--color-muted)}#session-image-lightbox .dialog-header .icon-button{flex-shrink:0;place-items:center;width:30px;height:30px;min-height:30px;padding:6px;display:grid}#session-image-lightbox .dialog-header .icon{stroke-width:1.8px}.session-image-previous .icon{transform:rotate(180deg)}.session-image-stage{background:var(--color-soft);border-radius:8px;justify-content:center;align-items:center;height:min(70dvh,760px);min-height:160px;display:flex;overflow:auto}.session-image-stage img{object-fit:contain;width:auto;max-width:100%;height:auto;max-height:100%}.session-image-stage.original-size{display:block}.session-image-stage.original-size img{max-width:none;max-height:none;margin:auto;display:block}.session-file{width:auto;max-width:100%}.session-file-name{border:1px solid var(--color-line);background:var(--color-soft);max-width:100%;color:inherit;border-radius:8px;align-items:center;gap:6px;padding:6px 10px;display:flex}.session-file-name span,.session-image-unavailable span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.session-file:has(.session-image-remove) .session-file-name{padding-right:32px}.session-file .session-image-status{top:3px;left:2px}.session-image-unavailable{font-size:var(--text-xs);align-content:center;gap:2px;padding:4px}.execution-status{color:var(--color-muted);vertical-align:middle;align-items:center;display:inline-flex}.execution-status.is-spinning svg{animation:1.2s linear infinite execution-status-spin}@keyframes execution-status-spin{to{transform:rotate(360deg)}}@media (prefers-reduced-motion:reduce){.execution-status.is-spinning svg{animation:none}}.tool-details{min-width:0;color:var(--color-muted);font-size:var(--text-sm);margin:10px 0}.tool-summary{cursor:pointer;align-items:center;gap:8px;min-height:32px;padding:6px 0;list-style:none;display:flex}.tool-details>summary::-webkit-details-marker{display:none}.tool-summary>.icon{flex-shrink:0;width:12px;height:12px}.tool-details[open]>.tool-summary>.icon,.tool-summary[aria-expanded=true]>.icon{transform:rotate(90deg)}.tool-details-label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.tool-details-status{font-size:var(--text-xs);flex-shrink:0;gap:6px;display:flex}.tool-details pre{border-left:1px solid var(--color-line);background:var(--color-soft);border-radius:0 var(--radius-sm) var(--radius-sm) 0;white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;font-size:var(--text-xs);margin:4px 0 14px 20px;padding:12px 16px;line-height:1.65;overflow:auto}.computer-messages{width:100%;max-width:820px;margin:0 auto}.computer-user-entry{margin:16px 0}.computer-user-entry .assistant-bubble-row{margin-bottom:0}.computer-message-actions{opacity:0;justify-content:flex-end;gap:4px;padding-top:4px;transition:opacity .12s;display:flex}.computer-user-entry:hover .computer-message-actions,.computer-user-entry:focus-within .computer-message-actions{opacity:1}.computer-message-actions .icon-button,.computer-message-edit-footer .icon-button{width:28px;height:28px;min-height:28px;color:var(--color-muted);padding:6px}.computer-message-actions .icon{width:14px;height:14px}.computer-user-entry.editing .assistant-bubble{width:min(100%,640px)}.computer-message-edit textarea{resize:none;background:var(--color-surface);width:100%;min-height:40px;max-height:240px;line-height:1.7}.computer-message-edit-footer{align-items:center;gap:6px;margin-top:8px;display:flex}.computer-message-edit-footer small{color:var(--color-muted);font-size:var(--text-xs);margin-right:auto}@media (hover:none){.computer-message-actions{opacity:1}}.computer-agent-message{overflow-wrap:anywhere;min-width:0;margin:24px 0}.computer-agent-message .markdown{font-size:var(--text-base);line-height:1.8}.computer-agent-message .markdown>:first-child{margin-top:0}.computer-agent-message .markdown>:last-child{margin-bottom:0}.computer-agent-message .markdown :is(h1,h2){font-size:18px}.computer-agent-message .markdown :is(h3,h4,h5,h6){font-size:var(--text-base)}.computer-agent-message .markdown pre{max-width:100%;overflow-x:auto}.computer-commentary{margin:20px 0}.computer-tool-group>button{width:100%;color:inherit;font:inherit;text-align:start;background:0 0;border:0;justify-content:flex-start}.computer-tool-group>button:hover{color:var(--color-text)}.computer-tool-list{border-inline-start:1px solid var(--color-line);margin-inline-start:6px;padding-inline-start:12px}.computer-tool-list .computer-tool{margin:0}.computer-divider{color:var(--color-muted);font-size:var(--text-xs);text-align:center;align-items:center;gap:14px;margin:28px 0;line-height:1.6;display:flex}.computer-divider:before,.computer-divider:after{content:"";border-top:1px solid var(--color-line);flex:1;min-width:16px}.computer-divider>span{overflow-wrap:anywhere;max-width:80%}.inline-reply{width:clamp(180px, var(--reply-width,180px), 600px);border:1px solid var(--color-line);border-radius:var(--radius-sm);background:0 0;align-items:flex-end;gap:4px;max-width:100%;padding:3px 6px;display:flex}.inline-reply:focus-within{border-color:var(--color-input-focus)}.inline-reply textarea{width:100%;min-width:0;min-height:28px;max-height:180px;font-size:var(--text-sm);resize:none;box-shadow:none;background:0 0;border:0;padding:3px 2px;line-height:22px}.inline-reply textarea:focus{box-shadow:none;outline:none}.inline-reply-send{background:0 0;border:0;flex:0 0 26px;place-items:center;width:26px;height:28px;min-height:28px;padding:3px;display:grid}.native-question{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.native-question>*{min-width:0}.native-question-part{grid-template-columns:minmax(0,1fr);justify-items:start;gap:8px;min-width:0;display:grid}.native-question-part>p{color:var(--color-text);font-size:var(--text-base);margin:0}.question-options,.question-actions{flex-wrap:wrap;align-items:stretch;gap:8px;max-width:100%;display:flex}.question-options button,.question-actions>button{min-height:var(--control-height);margin:0;line-height:20px}.question-options button{text-align:left;min-width:0;max-width:100%;height:36px;min-height:36px;font-size:var(--text-sm);white-space:nowrap;flex-shrink:1;justify-content:flex-start;align-items:center;gap:6px;padding:6px 10px;font-weight:400;display:flex}.question-options button[aria-pressed=true]{border-color:var(--brand-orange);background:var(--color-accent-soft);color:var(--color-link)}.question-option-description,.question-option-separator{color:var(--color-muted);font-size:inherit}.question-option-description{text-overflow:ellipsis;min-width:0;overflow:hidden}.question-option-separator{flex-shrink:0}.question-option-label{flex-shrink:0;align-items:center;gap:8px;max-width:100%;display:flex;overflow:hidden}.question-check{border:1px solid;border-radius:3px;flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.question-check .icon{width:12px;height:12px}.question-response,.question-result{align-items:baseline;gap:6px;display:flex}.question-response span{white-space:pre-wrap;overflow-wrap:anywhere}.question-result{color:var(--color-muted);font-size:var(--text-xs)}.question-response .icon,.question-result .icon{width:12px;height:12px;color:var(--color-muted);flex-shrink:0}.native-approval-row{flex-wrap:wrap;align-items:flex-start;gap:8px 16px;display:flex}.native-approval-details{flex:240px;margin:0}.native-approval-options{align-items:center;gap:8px;display:flex}.native-approval-options button{min-width:64px;min-height:32px;font-size:var(--text-xs);white-space:nowrap;border-radius:999px;padding:4px 12px;line-height:22px}.native-approval-options button span{font-variant-numeric:tabular-nums;margin-left:2px}.native-approval-row>.question-result{align-self:center}@media (pointer:coarse){.native-approval-options button{min-height:44px}}.native-plan{border:1px solid var(--color-line);border-radius:12px;gap:16px;padding:18px 20px}.native-plan-heading{color:var(--color-muted);font-size:var(--text-sm);align-items:center;gap:8px;display:flex}.native-plan-content{overscroll-behavior:contain;scrollbar-width:thin;min-height:0;max-height:min(480px,50dvh);overflow:auto}.native-plan .markdown :is(h1,h2){font-size:var(--text-lg);margin:18px 0 10px}.native-plan .markdown>:first-child{margin-top:0}.native-plan-history summary{cursor:pointer;color:var(--color-muted)}.native-plan-history[open] summary{margin-bottom:16px}.native-plan-actions{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:1fr;width:min(100%,360px);display:grid}.native-plan-actions-expanded{grid-template-columns:repeat(2,minmax(0,1fr))}.native-plan-actions>button{min-width:0;padding:10px 8px}.native-plan-note{font-size:var(--text-xs);margin-top:-8px;line-height:1.6}.native-plan-feedback{gap:10px;display:grid}.native-plan-feedback label{font-size:var(--text-sm);gap:6px;display:grid}.native-plan-feedback textarea{width:100%;min-height:96px;font-size:var(--text-base)}.native-plan-feedback-actions{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,280px);display:grid}.native-plan-feedback-actions>button{min-width:0;padding:10px 8px}@media (width<=600px){.native-plan{padding:12px}.native-plan-content{max-height:240px}}.composer-menu .dropdown-trigger{height:30px;min-height:30px;font-size:var(--text-xs);color:var(--color-muted);background:var(--color-soft);border-radius:18px;align-items:center;gap:4px;max-width:min(190px,100%);padding:5px 9px;display:flex}.composer-menu .dropdown-trigger>span{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.composer-menu .dropdown-trigger:hover,.composer-menu .dropdown-trigger[aria-expanded=true]{color:var(--color-text);background:var(--color-hover)}.composer-commands .dropdown-trigger{background:var(--color-soft);border-radius:50%;justify-content:center;width:30px;padding:6px}.composer-menu .dropdown-menu{--dropdown-max-height:45dvh;width:300px;max-width:calc(100vw - var(--sidebar-width) - 32px);max-height:45dvh;top:auto;bottom:calc(100% + 12px)}.composer-menu .dropdown-menu [role=menuitem]{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:10px}.composer-option-copy{text-align:left;flex-direction:column;gap:3px;min-width:0;display:flex}.composer-option-copy small,.composer-menu-heading small{font-size:var(--text-xs);color:var(--color-muted);font-weight:400}.composer-menu code{color:var(--color-muted);background:0 0;font-size:11px}.composer-menu-heading{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:8px 10px;display:flex}@media (width<=600px){.composer-menu .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px);max-width:none}.composer-menu .dropdown-trigger{max-width:min(140px,100%)}}.composer-choice{flex:0 auto;min-width:0}.composer-commands{flex-shrink:0}.composer-commands .icon{width:17px;height:17px}.composer-commands .dropdown-menu{width:640px}.composer-commands .dropdown-menu [role=menuitem]{padding:8px 10px}.composer-command-row{align-items:center;gap:20px;width:100%;min-width:0;display:flex}.composer-command-name{flex:0 190px;min-width:0}.composer-command-row small{min-width:0;color:var(--color-muted);font-weight:400;font-size:var(--text-xs);flex:1}.composer-command-row>*{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=600px){.composer-commands .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px)}.composer-command-name{flex-basis:42%}.composer-command-row{gap:10px}}.composer-option-copy small{text-overflow:ellipsis;white-space:nowrap;max-width:260px;overflow:hidden}@media (width<=600px){.computers-layout .message-composer-actions{flex-wrap:wrap;row-gap:8px}.computers-layout .message-composer-footer{align-items:flex-end}}.computer-panel{border-bottom:1px solid var(--color-line);max-height:55vh;padding:16px 24px;overflow:auto}.computer-control-status{margin:0;padding:4px 24px;font-size:12px}@media (width<=760px){.computer-panel{padding:12px}}.computer-tree .tree-name{flex:1}.computer-panel{flex-shrink:0}.computers-layout dialog .computer-panel{border:0;max-height:70dvh;padding:0}.computer-create-menu .dropdown-trigger{place-items:center;width:32px;height:32px;padding:4px;display:grid}.computer-create-menu .dropdown-menu{width:180px;left:auto;right:0}.session-rename{min-height:0;font:inherit;font-weight:inherit;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:0;border-radius:0;max-width:100%;padding:0;display:block;overflow:hidden}.session-rename:hover{color:var(--color-muted);background:0 0}.session-title-form{flex:1;min-width:0;margin-right:16px}.session-title-form input{width:100%}.computers-layout .message-composer{align-self:center;width:calc(100% - 56px);max-width:844px}.computers-layout .message-composer :is(.message-composer-actions,.session-images) .icon>*{vector-effect:non-scaling-stroke;stroke-width:1.6px}@media (width<=900px){.computers-layout .message-composer{width:calc(100% - 32px)}}@media (width<=600px){.computers-layout .message-composer{width:calc(100% - 16px)}}.computer-session-copy{flex-direction:column;flex:1;align-items:flex-start;gap:3px;min-width:0;padding:3px 0;display:flex}.computer-session-copy .tree-name{max-width:100%}.computer-session-copy time{color:var(--color-muted);font-size:var(--text-xs);font-weight:400;line-height:1.3}.computer-tree-row{align-items:center;min-width:0;display:flex}.computer-tree-row>.tree-item{flex:1;min-width:0}.computer-tree-action.icon-button{opacity:0;width:26px;height:26px;min-height:26px;color:var(--color-muted);margin-right:4px;padding:5px}.computer-tree-action.pinned,.computer-tree-row:hover>.computer-tree-action,.computer-tree-row:focus-within>.computer-tree-action{opacity:1}@media (hover:none){.computer-tree-action.icon-button{opacity:1}}.computer-session-row>.tree-item{flex:0 auto;width:auto;max-width:calc(100% - 28px)}.computer-session-pin.icon-button{align-self:flex-start;width:24px;height:24px;min-height:24px;margin:9px 0 0 -8px;padding:6px}.computer-session-pin .icon{width:12px;height:12px}.computer-session-pin:hover{color:var(--color-text)}.computer-navigation{flex-shrink:0;padding:4px}.computer-create-options{flex-wrap:wrap;align-items:center;gap:8px;display:flex}.computer-create-options>button:not(.primary){color:var(--color-muted);background:0 0;border-color:#0000;padding-inline:8px}.computer-create-options>.primary{margin-left:auto}@media (width<=680px){.computers-layout{grid-template-rows:clamp(140px,32dvh,280px) minmax(0,1fr)}}.computer-create-scope{font-size:var(--text-sm);margin:0}
@@ -0,0 +1,12 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-DDJO3cDO.js","./Dropdown-D625ln2m.js","./index-DjMoKD7A.js","./index-u6KD7Soy.css","./Markdown-Cw4CQNYb.js","./project-links-DI2fBvjw.js","./TerminalPane-BrSy-0jI.css"])))=>i.map(i=>d[i]);
2
+ import{A as e,C as t,E as n,Q as r,St as i,T as a,_t as o,c as s,ct as c,d as l,dt as u,ft as d,ht as f,k as p,l as m,lt as h,ot as g,p as _,pt as v,st as y,t as b,v as x,w as S,x as C,xt as w}from"./Dropdown-D625ln2m.js";import{A as T,C as E,L as D,M as O,P as k,R as A,S as j,_ as ee,a as te,b as M,c as ne,d as N,f as re,g as P,h as F,l as ie,m as ae,o as oe,p as se,s as ce,t as le,u as ue,v as de,y as I,z as fe}from"./index-DjMoKD7A.js";import{i as pe,t as me}from"./Markdown-Cw4CQNYb.js";import{a as he,i as ge,n as _e,t as L}from"./Conversation-CSGUsjrV.js";import{n as R,t as ve}from"./MessageComposer-B8Oa9gpY.js";import{l as ye,r as be}from"./WorkspaceTree-BHdUglYr.js";var z=w(),B=a();function xe({title:e,busy:t,onSave:n}){let[r,i]=(0,z.useState)(!1),[a,o]=(0,z.useState)(e);return r?(0,B.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,B.jsx)(`input`,{autoFocus:!0,"aria-label":`会话标题`,value:a,disabled:t,onChange:e=>o(e.target.value),onBlur:()=>i(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i(!1))}})}):(0,B.jsx)(`h2`,{children:(0,B.jsx)(`button`,{type:`button`,className:`session-rename`,title:`重命名会话`,"aria-label":`重命名会话:${e}`,onClick:()=>{o(e),i(!0)},children:e})})}var Se=v({id:f().uuid(),directory:f(),title:f(),cwd:f(),createdAt:f(),state:g([`running`,`exited`]),exitCode:d().nullable()}),V={id:f().uuid(),directory:f().min(1).max(200)},Ce={cols:d().int().min(2).max(500),rows:d().int().min(1).max(300)};h(`type`,[v({type:u(`create`),...V,...Ce,title:f().trim().min(1).max(160)}),v({type:u(`attach`),...V}),v({type:u(`detach`),...V}),v({type:u(`input`),...V,data:f().max(65536)}),v({type:u(`resize`),...V,...Ce}),v({type:u(`rename`),...V,title:f().trim().min(1).max(160)}),v({type:u(`close`),...V})]);var we=h(`type`,[v({type:u(`size`),id:f(),...Ce}),v({type:u(`inventory`),directories:y(f()),terminals:y(Se)}),v({type:u(`snapshot`),id:f(),data:f(),cols:d(),rows:d(),seq:d()}),v({type:u(`output`),id:f(),data:f(),seq:d()}),v({type:u(`result`),id:f(),operation:f(),error:f().optional()})]);function Te(e,t){let n=(0,z.useRef)(null),r=(0,z.useRef)(new Set),[a,o]=(0,z.useState)(!1),[s,c]=(0,z.useState)([]),[l,u]=(0,z.useState)([]);(0,z.useEffect)(()=>{if(!t)return;let a=!1,s,l,d=()=>{let t=new URL(i(`/api/v1/projects/${encodeURIComponent(e)}/web/terminals`),location.origin);t.protocol=t.protocol===`https:`?`wss:`:`ws:`,l=new WebSocket(t),n.current=l,l.onmessage=e=>{let t=we.safeParse(JSON.parse(e.data));if(!t.success||a)return;let n=t.data;n.type===`inventory`&&(u(n.terminals),c(n.directories),o(!0));for(let e of r.current)e(n)},l.onclose=()=>{o(!1),c([]),a||(s=setTimeout(d,2e3))}};return d(),()=>{a=!0,clearTimeout(s),l?.close(),n.current=null}},[e,t]);let d=(0,z.useCallback)(e=>(r.current.add(e),()=>{r.current.delete(e)}),[]),f=(0,z.useCallback)(e=>{if(n.current?.readyState!==WebSocket.OPEN)throw Error(`终端连接已断开,输入未发送。`);n.current.send(JSON.stringify(e))},[]);return{connected:a,directories:s,terminals:l,subscribe:d,send:f,request:(0,z.useCallback)(e=>new Promise((t,n)=>{let r=setTimeout(()=>{i(),n(Error(`暂未收到结果,请检查连接;操作不会自动重发。`))},15e3),i=d(a=>{a.type===`result`&&a.id===e.id&&a.operation===e.type&&(clearTimeout(r),i(),a.error?n(Error(a.error)):t())});try{f(e)}catch(e){clearTimeout(r),i(),n(e)}}),[f,d])}}v({provider:re,cursor:f().optional(),session:F.optional()});var Ee=v({id:F,title:f(),cwd:f(),updatedAt:f().datetime().nullable(),active:c().default(!1)}),De=v({sessions:y(Ee),nextCursor:f().nullable()}),Oe=v({command:P,history:De.nullable()});function ke(e,t=Date.now()){if(!e)return``;let n=new Date(e),r=Math.max(0,t-n.getTime());return Number.isFinite(r)?r<36e5?`${Math.floor(r/6e4)}min`:r<864e5?`${Math.floor(r/36e5)}h`:r<=6048e5?`${Math.floor(r/864e5)}day`:`${String(n.getFullYear()).slice(-2)}/${String(n.getMonth()+1).padStart(2,`0`)}/${String(n.getDate()).padStart(2,`0`)}`:``}function Ae({id:e,label:t,value:n,onChange:r,options:i,placeholder:a,loading:o=!1,disabled:s=!1,empty:c=`没有匹配的选项。`,footer:l}){let[u,d]=(0,z.useState)(!1),[f,p]=(0,z.useState)(``),[h,g]=(0,z.useState)(),_=(0,z.useRef)(null),v=(0,z.useRef)(null),y=(0,z.useRef)(null),b=i.find(e=>e.value===n),x=b?``:n.trim().toLocaleLowerCase(),S=i.filter(e=>`${e.label} ${e.value}`.toLocaleLowerCase().includes(x)),C=S.filter(e=>!e.disabled),w=S.findIndex(e=>e.value===f);(0,z.useEffect)(()=>p(``),[n]),(0,z.useEffect)(()=>{if(!u)return;let e=e=>{_.current?.contains(e.target)||d(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),(0,z.useLayoutEffect)(()=>{if(!u)return;let e=()=>{let e=v.current?.getBoundingClientRect();if(!e)return;let t=innerHeight-e.bottom-16,n=e.top-16,r=t<220&&n>t;g({left:e.left,width:e.width,top:r?void 0:e.bottom+6,bottom:r?innerHeight-e.top+6:void 0,maxHeight:Math.min(320,r?n:t)})};return e(),window.addEventListener(`resize`,e),window.addEventListener(`scroll`,e,!0),()=>{window.removeEventListener(`resize`,e),window.removeEventListener(`scroll`,e,!0)}},[u]),(0,z.useEffect)(()=>{u&&w>=0&&document.getElementById(`${e}-option-${w}`)?.scrollIntoView({block:`nearest`})},[u,w,e]);function T(e){e.disabled||(r(e.value),d(!1),y.current?.focus())}return(0,B.jsxs)(`div`,{className:`combobox`,ref:_,onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||d(!1)},onKeyDown:e=>{e.key===`Escape`&&u&&(e.preventDefault(),e.stopPropagation(),d(!1),y.current?.focus())},children:[(0,B.jsxs)(`div`,{className:`combobox-field`,ref:v,children:[(0,B.jsx)(`input`,{id:e,ref:y,role:`combobox`,"aria-label":t,"aria-autocomplete":`list`,"aria-expanded":u,"aria-controls":`${e}-list`,"aria-activedescendant":u&&w>=0?`${e}-option-${w}`:void 0,autoComplete:`off`,disabled:s,value:b?.label??n,title:b?.value,placeholder:a,onClick:()=>d(!0),onChange:e=>{r(e.target.value),d(!0)},onKeyDown:e=>{if([`ArrowDown`,`ArrowUp`].includes(e.key)){e.preventDefault(),d(!0);let t=C.findIndex(e=>e.value===f),n=t<0?e.key===`ArrowDown`?0:C.length-1:(t+(e.key===`ArrowDown`?1:-1)+C.length)%C.length;p(C[n]?.value??``)}else e.key===`Enter`&&u&&w>=0?(e.preventDefault(),T(S[w])):e.key===`Tab`&&d(!1)}}),(0,B.jsx)(m,{icon:u?`chevronUp`:`chevronDown`,label:`${u?`收起`:`展开`}${t}`,disabled:s,"aria-expanded":u,"aria-controls":`${e}-list`,onClick:()=>{d(!u),y.current?.focus()}})]}),u&&(0,B.jsxs)(`div`,{className:`combobox-popup`,style:h,children:[(0,B.jsxs)(`div`,{id:`${e}-list`,role:`listbox`,"aria-label":t,"aria-busy":o,children:[S.map((t,r)=>(0,B.jsxs)(`button`,{id:`${e}-option-${r}`,type:`button`,role:`option`,"aria-selected":t.value===n,disabled:t.disabled,tabIndex:-1,className:`combobox-option ${t.value===f?`active`:``}`,title:`${t.label} · ${t.value}`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(t),children:[(0,B.jsxs)(`span`,{className:`combobox-option-copy`,children:[(0,B.jsx)(`span`,{children:t.label}),t.description&&(0,B.jsx)(`small`,{children:t.description})]}),t.detail&&(0,B.jsx)(`span`,{className:`combobox-option-detail`,children:t.detail})]},t.value)),o&&(0,B.jsx)(`p`,{className:`combobox-message`,role:`status`,children:`正在读取…`}),!o&&!S.length&&(0,B.jsx)(`p`,{className:`combobox-message`,children:c})]}),l&&(0,B.jsx)(`div`,{className:`combobox-footer`,children:l})]})]})}function je({directory:t,provider:n,providers:r,sessions:i,request:a,onClose:o,onImport:s}){let[c,u]=(0,z.useState)(n),[d,f]=(0,z.useState)([]),[h,g]=(0,z.useState)(null),[v,y]=(0,z.useState)(``),[b,x]=(0,z.useState)(null),[S,C]=(0,z.useState)(``),w=(0,z.useRef)(null),T=e=>i.find(t=>!t.hidden&&t.provider===c&&(t.nativeSession??t.resumeSession)===e);async function E(n,r){let i=e();for(await a(`web/local-agents/${t}/history`,P,{method:`POST`,signal:r,body:{id:i,argument:JSON.stringify({provider:c,...n})}});!r.aborted;){let e=await a(`web/local-agents/${t}/history/${i}`,Oe,{signal:r});if(e.command.state===`succeeded`&&e.history)return{...e.history,id:i};if(![`queued`,`running`].includes(e.command.state))throw Error(e.command.error||`读取历史会话失败。`);await new Promise(e=>{let t=()=>{clearTimeout(n),r.removeEventListener(`abort`,t),e()},n=setTimeout(t,1e3);r.addEventListener(`abort`,t,{once:!0})})}throw new DOMException(`Aborted`,`AbortError`)}async function D(n,r,i){let o=T(n.id)??await a(`web/local-agents/${t}/sessions`,ae,{method:`POST`,signal:i,body:{id:e(),title:n.title,provider:c,resumeSession:n.id,historyRequest:r}});i.aborted||s(o)}async function O(e,t){w.current?.abort();let n=new AbortController;w.current=n,x(e),C(``);try{await t(n.signal)}catch(e){n.signal.aborted||C(p(e))}finally{n.signal.aborted||x(null)}}let k=e=>O(`list`,async t=>{let n=await E(e?{cursor:e}:{},t);t.aborted||(f(t=>{let r=[...e?t:[],...n.sessions.map(e=>({...e,requestId:n.id}))];return[...new Map(r.map(e=>[e.id,e])).values()].sort((e,t)=>(t.updatedAt??``).localeCompare(e.updatedAt??``))}),g(n.nextCursor))});(0,z.useEffect)(()=>(f([]),g(null),y(``),k(),()=>w.current?.abort()),[c,t,a]);let A=d.find(e=>e.id===v),j=b===`import`;return(0,B.jsx)(l,{id:`computer-import-session`,title:`导入历史会话`,onClose:o,children:(0,B.jsxs)(`form`,{className:`native-history`,onSubmit:e=>{e.preventDefault(),O(`import`,async e=>{let t=v.trim(),n=T(t);if(n)return s(n);if(A)return D(A,A.requestId,e);let r=await E({session:t},e),i=r.sessions.find(e=>e.id===t);if(!i)throw Error(`找不到此目录中的会话。`);await D(i,r.id,e)})},children:[(0,B.jsx)(oe,{label:`历史会话 Agent`,value:c,onChange:u,providers:[n,...r],disabled:j}),(0,B.jsxs)(`div`,{className:`field`,children:[(0,B.jsx)(`label`,{htmlFor:`native-history-session`,children:`Session`}),(0,B.jsxs)(`div`,{className:`native-history-input-row`,children:[(0,B.jsx)(Ae,{id:`native-history-session`,label:`历史会话`,value:v,onChange:y,placeholder:`选择会话或输入 ID`,disabled:j,loading:b===`list`,empty:v?`未找到匹配会话,可直接输入 Session ID。`:`此目录暂无历史会话,可输入 Session ID。`,options:d.map(e=>({value:e.id,label:e.title,description:e.id,detail:T(e.id)?`已接入`:e.active?`工作中`:ke(e.updatedAt),disabled:e.active&&!T(e.id)})),footer:(0,B.jsxs)(B.Fragment,{children:[h&&(0,B.jsx)(`button`,{className:`native-history-more`,type:`button`,disabled:!!b,onClick:()=>void k(h),children:`加载更多`}),(0,B.jsx)(m,{icon:`refresh`,label:`刷新历史会话`,disabled:!!b,onClick:()=>void k()})]})},c),(0,B.jsx)(`button`,{type:`submit`,disabled:j||!F.safeParse(v.trim()).success||!!A?.active&&!T(A.id),children:j?`正在导入…`:T(v.trim())?`打开`:`导入`})]})]}),(0,B.jsx)(_,{error:!0,children:S}),(0,B.jsx)(`small`,{className:`muted`,children:`请先退出原终端会话。`})]})})}var H={png:`image/png`,jpg:`image/jpeg`,jpeg:`image/jpeg`,webp:`image/webp`,gif:`image/gif`,avif:`image/avif`,bmp:`image/bmp`,ico:`image/x-icon`,svg:`image/svg+xml`};function Me(e,t){let n=e.toLowerCase().split(`.`).at(-1)??``;return t&&Object.values(H).includes(t)?t:Object.hasOwn(H,n)?H[n]:n===`pdf`?`application/pdf`:/^(md|markdown|mdown)$/.test(n)?`text/markdown`:/^html?$/.test(n)?`text/html`:/^(txt|log|csv|tsv|jsonl?|ndjson|ya?ml|toml|ini|cfg|conf|xml|sql|diff|patch|sh|bash|zsh|fish|py|js|jsx|mjs|cjs|ts|tsx|css|scss|vue|svelte|go|rs|c|cc|cpp|h|hpp|java|kt|swift|rb|lua|r|tex|rst|properties|env|lock)$/.test(n)||/^(readme|license|makefile|dockerfile|cmakelists\.txt|\.gitignore)$/i.test(e)?`text/plain`:``}async function Ne(e,t){let n=e.body.getReader(),r=[],i=0,a=(t??0)>E;try{for(;;){let{done:e,value:t}=await n.read();if(e)break;let o=Math.min(t.length,E-i);if(r.push(t.slice(0,o)),i+=o,o<t.length||a&&i===524288){a=!0;break}}}finally{await n.cancel(),n.releaseLock()}return{blob:new Blob(r),truncated:a}}async function Pe(e,t,n,r){let i=e.previewUrl??e.url;if(i.startsWith(`data:`)&&t.startsWith(`image/`))return{format:t,preview:i,download:i};if(!t&&!e.previewUrl)return{format:``};let a=await fetch(i,{credentials:`same-origin`,cache:`no-store`,signal:n});if(!a.ok)throw Error((await a.json().catch(()=>null))?.error?.message??`文件暂不可用。`);if(!t)return await a.body?.cancel(),{format:``};if(t.startsWith(`text/`)){let n=a.headers.get(`X-Teammy-File-Size`)??a.headers.get(`Content-Length`),{blob:i,truncated:o}=await Ne(a,n===null?e.size:Number(n)),s=o?void 0:r(i.slice(0,i.size,`application/octet-stream`)),c;try{c=new TextDecoder(`utf-8`,{fatal:!0}).decode(await i.arrayBuffer(),{stream:o})}catch{return{format:``,download:s}}return c.includes(`\0`)?{format:``,download:s}:{format:t,text:c,truncated:o,download:s}}let o=await a.blob();if(t===`image/svg+xml`)return{format:t,preview:`data:image/svg+xml;charset=utf-8,`+encodeURIComponent(await o.text()),download:r(o.slice(0,o.size,`application/octet-stream`))};if(t===`application/pdf`&&(navigator.pdfViewerEnabled===!1||await o.slice(0,5).text()!==`%PDF-`))return{format:``,download:r(o.slice(0,o.size,`application/octet-stream`))};let s=r(o.slice(0,o.size,t));return{format:t,preview:s,download:s}}function Fe({file:e,onClose:t,gallery:n}){let[r,i]=(0,z.useState)(),[a,o]=(0,z.useState)(``),[c,u]=(0,z.useState)(!1),d=(0,z.useRef)(null),f=(0,z.useRef)(null),h=Me(e.name,e.mimeType),{name:g,url:v,previewUrl:y,size:b}=e;(0,z.useEffect)(()=>{let e=new AbortController,t;return i(void 0),o(``),u(!1),Pe({name:g,url:v,previewUrl:y,size:b},h,e.signal,n=>(e.signal.throwIfAborted(),t=URL.createObjectURL(n),t)).then(t=>{e.signal.aborted||i(t)}).catch(t=>{e.signal.aborted||o(p(t))}),d.current?.focus(),()=>{e.abort(),t&&URL.revokeObjectURL(t)}},[v,b,y,g,h]),(0,z.useEffect)(()=>{f.current?.scrollIntoView({block:`center`})},[r,e.line]);let x=e.line&&r?.text!==void 0?r.text.split(`
3
+ `):null,S=(e.line??1)-1,C=h.startsWith(`image/`);return(0,B.jsx)(l,{id:`session-image-lightbox`,title:e.name,label:C?`图片预览`:`文件预览`,onClose:t,onKeyDown:e=>{n&&[`ArrowLeft`,`ArrowRight`].includes(e.key)&&(e.preventDefault(),n.move(e.key===`ArrowLeft`?-1:1))},actions:(0,B.jsxs)(B.Fragment,{children:[n&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(m,{icon:`chevron`,className:`session-image-previous`,label:`上一张图片`,onClick:()=>n.move(-1)}),(0,B.jsxs)(`small`,{children:[n.index+1,` / `,n.count]}),(0,B.jsx)(m,{icon:`chevron`,label:`下一张图片`,onClick:()=>n.move(1)})]}),C&&r?.format&&(0,B.jsx)(m,{icon:c?`zoomOut`:`zoomIn`,label:c?`适合窗口`:`原始尺寸`,"aria-pressed":c,onClick:()=>u(!c)}),(0,B.jsx)(`a`,{className:`icon-button`,href:a?void 0:r?.download??e.url,"aria-disabled":!!a,download:e.name,"aria-label":`下载文件`,title:`下载文件`,children:(0,B.jsx)(s,{name:`download`})})]}),children:(0,B.jsx)(`div`,{ref:d,tabIndex:-1,className:`session-image-viewer`,children:a?(0,B.jsx)(_,{error:!0,children:a}):r?r.format?C?(0,B.jsx)(`div`,{className:`session-image-stage`+(c?` original-size`:``),children:(0,B.jsx)(`img`,{src:r.preview,alt:e.name,onError:()=>i({format:``,download:r.download})})}):r.format===`application/pdf`?(0,B.jsx)(`iframe`,{className:`file-preview-document`,src:r.preview,title:e.name+` 预览`}):r.format===`text/html`&&!e.line?(0,B.jsx)(ye,{name:e.name,url:e.url}):(0,B.jsxs)(`div`,{className:`file-preview-text`,children:[r.format===`text/markdown`&&!e.line?(0,B.jsx)(`article`,{className:`markdown`,children:(0,B.jsx)(me,{children:r.text??``})}):(0,B.jsx)(`pre`,{className:`raw`,children:x&&S<x.length?(0,B.jsxs)(B.Fragment,{children:[S>0&&x.slice(0,S).join(`
4
+ `)+`
5
+ `,(0,B.jsx)(`mark`,{ref:f,children:x[S]||` `}),x.length>S+1?`
6
+ `+x.slice(S+1).join(`
7
+ `):``]}):r.text}),r.truncated&&(0,B.jsx)(`small`,{children:`仅显示文件开头,可下载完整文件。`})]}):(0,B.jsx)(`p`,{className:`file-preview-empty`,children:`暂不支持预览此文件。`}):(0,B.jsx)(`p`,{role:`status`,children:`正在读取文件…`})})})}var Ie=[],Le=`image/png,image/jpeg,image/webp`;function U(e){if(`image/png,image/jpeg,image/webp`.split(`,`).includes(e.type))return e.type;if(e.type&&e.type!==`application/octet-stream`)return null;let t=e.name.split(`.`).at(-1)?.toLowerCase();return t===`png`?`image/png`:t===`jpg`||t===`jpeg`?`image/jpeg`:t===`webp`?`image/webp`:null}var Re=class{sessions=new Map;listeners=new Set;uploads=new Map;get=e=>this.sessions.get(e)??Ie;subscribe=e=>(this.listeners.add(e),()=>this.listeners.delete(e));set(e,t){this.sessions.set(e,t);for(let e of this.listeners)e()}patch(e,t,n){this.set(e,this.get(e).map(e=>e.id===t?{...e,...n}:e))}add(t,n,r,i=!1){if(!t||!n.length)return;if(n.length+this.get(t).length>4)return i?`每条消息最多添加 4 张图片。`:`每条消息最多添加 4 个附件。`;if(Array.from(n).some(e=>i&&(!U(e)||!e.size)||e.size>M))return i?`请选择不超过 2 GB 的 PNG、JPEG 或 WebP 图片。`:`每个附件最多 2 GB。`;let a=Array.from(n,t=>({id:e(),name:t.name.slice(0,200)||`附件`,imageOnly:i,file:t,state:`uploading`}));this.set(t,[...this.get(t),...a]);for(let e of a)this.upload(t,e.id,r)}remove(e,t){this.uploads.get(t)?.abort(),this.uploads.delete(t),this.set(e,this.get(e).filter(e=>e.id!==t))}async upload(e,t,i){let a=this.get(e).find(e=>e.id===t);if(!a?.file||this.uploads.has(t))return;let o=new AbortController;this.uploads.set(t,o),this.patch(e,t,{state:`uploading`,error:``});try{let n=a.file,s=`web/local-agent-sessions/${e}/attachments/${t}`,l;if(n.size>5242880){for(let l=a.uploaded??0;l<n.size;l+=I){let a=n.slice(l,l+I);await i(`${s}/parts/${l/I}?size=${n.size}`,v({ok:c()}),{method:`POST`,signal:o.signal,timeoutMs:r,body:a}),this.patch(e,t,{uploaded:l+a.size})}l=await i(`${s}/finish`,j,{method:`POST`,signal:o.signal,timeoutMs:r,body:{name:a.name,size:n.size,imageOnly:a.imageOnly}})}else{let s=await new Promise((e,t)=>{let r=new FileReader;r.onload=()=>e(String(r.result)),r.onerror=()=>t(Error(`附件读取失败。`)),r.onabort=()=>t(Error(`附件读取已取消。`)),o.signal.addEventListener(`abort`,()=>r.abort(),{once:!0}),r.readAsDataURL(n)});if(o.signal.aborted)return;U(n)&&this.patch(e,t,{preview:s}),l=await i(`web/local-agent-sessions/${e}/${a.imageOnly?`images`:`attachments`}`,j,{method:`POST`,signal:o.signal,timeoutMs:r,body:{id:t,name:a.name,data:s.split(`,`,2)[1]}})}o.signal.aborted||this.set(e,this.get(e).map(e=>e.id===t?{id:t,name:l.name,state:`ready`,attachment:l,imageOnly:e.imageOnly}:e))}catch(r){o.signal.aborted||this.patch(e,t,{state:`failed`,error:p(r),...r instanceof n&&r.code===`ATTACHMENT_INCOMPLETE`?{uploaded:0}:{}})}finally{this.uploads.get(t)===o&&this.uploads.delete(t)}}},ze=(e,t,n,r=!1)=>i(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/${r?`attachments`:`images`}/${encodeURIComponent(n)}`);function W({images:e,remove:t,retry:n,disabled:r=!1}){let[i,a]=(0,z.useState)(),[o,c]=(0,z.useState)([]),l=e.find(e=>e.id===i),u=e.filter(e=>!e.file&&!o.includes(e.id)),d=u.findIndex(e=>e.id===i);return e.length?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`session-image${e.file?` session-file`:``}`,children:[e.file?(0,B.jsxs)(`button`,{type:`button`,className:`session-file-name`,title:e.name,"aria-label":`预览附件 ${e.name}`,disabled:!e.url||e.state===`uploading`||e.state===`failed`,onClick:()=>a(e.id),children:[(0,B.jsx)(s,{name:`attachment`,size:`small`}),(0,B.jsx)(`span`,{children:e.name})]}):o.includes(e.id)?(0,B.jsxs)(`button`,{type:`button`,className:`session-image-preview session-image-unavailable`,title:`重新读取图片`,onClick:()=>c(t=>t.filter(t=>t!==e.id)),children:[(0,B.jsx)(s,{name:`refresh`,size:`small`}),(0,B.jsx)(`span`,{children:e.name}),(0,B.jsx)(`small`,{children:`图片暂不可用`})]}):(0,B.jsx)(`button`,{type:`button`,className:`session-image-preview`,"aria-label":`预览图片 ${e.name}`,title:e.name,disabled:!e.url,onClick:()=>a(e.id),children:e.url?(0,B.jsx)(`img`,{src:e.url,alt:e.name,loading:`lazy`,onError:()=>c(t=>[...t,e.id])}):(0,B.jsx)(s,{name:`image`})}),e.state===`uploading`&&(0,B.jsx)(`span`,{className:`session-image-status`,role:`status`,"aria-label":`正在上传 ${e.name}`,children:(0,B.jsx)(s,{name:`loading`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-status`,"aria-label":`重试上传 ${e.name}`,title:e.error,disabled:r,onClick:()=>n?.(e.id),children:(0,B.jsx)(s,{name:`refresh`,size:`small`})}),t&&(0,B.jsx)(`button`,{type:`button`,className:`session-image-remove`,"aria-label":`移除${e.file?`附件`:`图片`} ${e.name}`,disabled:r,onClick:()=>t(e.id),children:(0,B.jsx)(s,{name:`close`,size:`small`})}),e.state===`failed`&&(0,B.jsx)(`small`,{className:`session-image-error`,children:e.error})]},e.id))}),l&&(0,B.jsx)(Fe,{file:l,onClose:()=>a(void 0),gallery:d>=0&&u.length>1?{index:d,count:u.length,move:e=>a(u[(d+e+u.length)%u.length]?.id)}:void 0},l.id)]}):null}function G({images:e,url:t}){return(0,B.jsx)(W,{images:e.map(e=>({...e,file:e.mimeType===`application/octet-stream`,url:t(e.id)}))})}function Be(e,n,r){let i=S(),a=t(n,`computer-attachment-uploads`),c=(0,z.useMemo)(()=>{let e=i?.get(a)??new Re;return i?.set(a,e),e},[i,a]),l=(0,z.useSyncExternalStore)(c.subscribe,()=>c.get(e)),[u,d]=(0,z.useState)(``),f=(0,z.useRef)(null),m=(0,z.useRef)(null),h=`${n}:${e}`,g=(0,z.useRef)(h);g.current=h,(0,z.useEffect)(()=>d(``),[e,n]);let v=l.flatMap(e=>e.attachment?[e.attachment]:[]),y=l.some(e=>e.state===`uploading`),x=t=>ze(n,e,t,!0),C=(t,n=!1)=>d(c.add(e,t,r,n)??``);async function w(){try{let e=await navigator.clipboard.read(),t=[];for(let n of e){let e=n.types.find(e=>Le.split(`,`).includes(e));if(e){let r=await n.getType(e);t.push(new File([r],`剪贴板-${t.length+1}.${e.split(`/`)[1]}`,{type:e}))}}if(g.current!==h)return;t.length?C(t,!0):d(`剪贴板中没有可用的图片。`)}catch(e){g.current===h&&d(e instanceof DOMException&&e.name===`NotAllowedError`?`无法读取剪贴板,请在输入框中粘贴图片或选择图片文件。`:p(e))}}return{files:v,busy:y,count:l.length,failed:l.some(e=>e.state===`failed`),add:C,clear:()=>{for(let t of v)c.remove(e,t.id)},picker:(t,n)=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:m,type:`file`,className:`session-image-file`,multiple:!0,"aria-label":`选择附件`,disabled:t,onChange:e=>{e.target.files&&C(e.target.files),e.target.value=``}}),n&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`input`,{ref:f,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":`选择图片`,disabled:t,onChange:e=>{e.target.files&&C(e.target.files,!0),e.target.value=``}}),(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`添加图片`,title:`添加图片,也可粘贴或拖入`,disabled:t,onClick:()=>f.current?.click(),children:(0,B.jsx)(s,{name:`image`,size:`small`})})]}),(0,B.jsx)(b,{id:`session-attachments`,triggerId:`session-attachments-trigger`,label:`附件`,placement:`top`,className:`composer-menu composer-attachments`,routeKey:e,disabled:t,trigger:(0,B.jsx)(s,{name:`attachment`,size:`small`}),children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{e(),m.current?.click()},children:[(0,B.jsx)(s,{name:`attachment`,size:`small`}),`选择文件`]}),n&&typeof navigator.clipboard?.read==`function`&&(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{e(),w()},children:[(0,B.jsx)(s,{name:`paste`,size:`small`}),`粘贴图片`]})]})})]}),preview:t=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(W,{images:l.map(e=>({id:e.id,name:e.name,mimeType:e.attachment?.mimeType??e.file?.type,url:e.attachment?x(e.id):e.preview??``,size:e.attachment?.size??e.file?.size??0,file:e.attachment?e.attachment.mimeType===`application/octet-stream`:!!e.file&&(e.file.size>5242880||!U(e.file)),state:e.state,...e.error?{error:e.error}:{}})),disabled:t,remove:t=>{c.remove(e,t),r(`web/local-agent-sessions/${e}/attachments/${t}`,o(),{method:`DELETE`}).catch(()=>{})},retry:t=>void c.upload(e,t,r)}),(0,B.jsx)(_,{error:!0,children:u})]})}}var Ve={offered:{label:`待本地接收`,icon:`clock`},received:{label:`待本地接收`,icon:`clock`},queued:{label:`排队中`,icon:`clock`},dispatching:{label:`正在连接`,icon:`loading`,spinning:!0},running:{label:`执行中`,icon:`loading`,spinning:!0},cancelled:{label:`已撤回`,icon:`close`},interrupted:{label:`已停止`,icon:`stop`},failed:{label:`未能执行`,icon:`warning`},human_routed:{label:`未送达本地`,icon:`warning`},uncertain:{label:`需要核对`,icon:`warning`}};function He({state:e,error:t}){let n=Ve[e];if(!n)return null;let r=t?`${n.label}:${t}`:n.label;return(0,B.jsx)(`span`,{className:`execution-status${n.spinning?` is-spinning`:``}`,role:`img`,"aria-label":r,title:r,children:(0,B.jsx)(s,{name:n.icon,size:`small`})})}function Ue({message:e}){return!e.queue||e.queue.state===`running`?null:(0,B.jsx)(He,{state:e.queue.state,error:e.queue.error})}function We({message:t,images:n,status:r,rewind:i,onFile:a}){let o=i?.commands.find(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)&&JSON.parse(e.argument).messageId===t.id),[c,l]=(0,z.useState)(!!o),[u,d]=(0,z.useState)(o?JSON.parse(o.argument).body:t.body),[f,h]=(0,z.useState)(!1),[g,v]=(0,z.useState)(``),[y,b]=(0,z.useState)(!1),[S,C]=(0,z.useState)(),w=(0,z.useRef)(void 0),T=R(u);(0,z.useLayoutEffect)(()=>{c&&T.current&&(T.current.style.height=`0px`,T.current.style.height=`${T.current.scrollHeight}px`)},[c]);let E=i?.commands.find(e=>e.id===S?.id)??S??o,D=y||E&&[`queued`,`running`].includes(E.state),O=i?.available&&t.source===`web_session`&&t.id.startsWith(`input:`)&&(!t.queue||[`handled`,`interrupted`].includes(t.queue.state));async function k(){if(!i||D||!u.trim())return;let n=JSON.stringify({messageId:t.id,body:u.trim(),expectedLastMessage:i.expectedLastMessage});(E&&[`failed`,`uncertain`].includes(E.state)||w.current?.argument!==n)&&(w.current={id:e(),argument:n}),b(!0),v(``);try{let e=await i.request(`web/local-agent-sessions/${i.session}/commands`,P,{method:`POST`,body:{id:w.current.id,kind:`rewind`,argument:w.current.argument}});C(e),i.refresh()}catch(e){v(p(e))}finally{b(!1)}}return(0,B.jsxs)(`div`,{className:`computer-user-entry${c?` editing`:``}`,children:[(0,B.jsxs)(L,{mine:!0,author:`你`,time:t.createdAt,children:[n,c?(0,B.jsxs)(`form`,{className:`computer-message-edit`,onSubmit:e=>{e.preventDefault(),k()},children:[(0,B.jsx)(`textarea`,{ref:T,"aria-label":`编辑历史消息`,value:u,onChange:e=>d(e.target.value),disabled:!!D,autoFocus:!0,rows:1}),(0,B.jsxs)(`div`,{className:`computer-message-edit-footer`,children:[(0,B.jsx)(`small`,{children:`替换此后的对话,保留工作区文件`}),(0,B.jsx)(m,{icon:`close`,label:`取消编辑`,disabled:!!D,onClick:()=>{l(!1),v(``),d(t.body)}}),(0,B.jsx)(`button`,{type:`submit`,className:`message-send primary`,"aria-label":D?`正在回退`:`从此处继续`,title:D?`正在回退`:`从此处继续`,disabled:!!D||!u.trim(),children:(0,B.jsx)(s,{name:D?`loading`:`send`,size:`small`})})]}),(0,B.jsx)(_,{error:!0,children:g||(E&&[`failed`,`uncertain`].includes(E.state)?E.error:``)})]}):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(me,{onFile:a,children:t.body})}),!c&&r]}),!c&&(0,B.jsxs)(`div`,{className:`computer-message-actions`,children:[(0,B.jsx)(m,{icon:f?`check`:`copy`,label:f?`已复制`:`复制消息`,onClick:()=>{x(t.body).then(()=>h(!0)).catch(e=>v(p(e)))}}),O&&(0,B.jsx)(m,{icon:`edit`,label:`编辑并从此处继续`,onClick:()=>{d(t.body),l(!0)}})]}),!c&&(0,B.jsx)(_,{error:!0,children:g})]})}function Ge({label:e,meta:t,children:n,className:r=``,onToggle:i}){return(0,B.jsxs)(`details`,{className:`tool-details ${r}`,onToggle:i,children:[(0,B.jsxs)(`summary`,{className:`tool-summary`,title:e,children:[(0,B.jsx)(s,{name:`chevron`,size:`small`}),(0,B.jsx)(`span`,{className:`tool-details-label`,children:e}),t&&(0,B.jsx)(`span`,{className:`tool-details-status`,children:t})]}),n]})}function K(e){if(e<1e3)return`不到 1 秒`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return[r?`${r} 小时`:``,n%60?`${n%60} 分`:``,t%60?`${t%60} 秒`:``].filter(Boolean).join(` `)}function q({children:e}){return(0,B.jsx)(`div`,{className:`computer-divider`,children:(0,B.jsx)(`span`,{children:e})})}function J({message:e}){let t=e.state===`succeeded`?`已工作`:e.state===`interrupted`?`已停止`:e.state===`failed`?`执行失败`:`需要核对`;return(0,B.jsxs)(q,{children:[t,e.activity?.durationMs===void 0?``:` · ${K(e.activity.durationMs)}`]})}var Y={offered:`待本地接收`,pending:`待投递`,human_routed:`未送达本地`,failed:`失败`,uncertain:`需要核对`};function Ke(e){let t=[];for(let n of e)if(n.role===`assistant`&&n.activity?.kind===`tool`&&!n.question){let e=t.at(-1);Array.isArray(e)&&e[0].activity?.turnId===n.activity.turnId?e.push(n):t.push([n])}else t.push(n);return t}function X({text:e,onFile:t}){let n=[],r=0;if(t)for(let{start:i,end:a,link:o}of pe(e))n.push(e.slice(r,i),(0,B.jsx)(`button`,{type:`button`,className:`computer-file-link`,onClick:()=>t(o),children:e.slice(i,a)},i)),r=a;return(0,B.jsxs)(`pre`,{children:[n,e.slice(r)]})}function qe({calls:e,onFile:t}){let n=(0,z.useId)(),[r,i]=(0,z.useState)(!1),a=e.length>1,o=[`failed`,`uncertain`,`interrupted`].find(t=>e.some(e=>e.state===t));return(0,B.jsxs)(`div`,{className:a?`tool-details computer-tool-group`:void 0,children:[a&&(0,B.jsxs)(`button`,{type:`button`,className:`tool-summary`,"aria-expanded":r,"aria-controls":n,onClick:()=>i(!r),children:[(0,B.jsx)(s,{name:`chevron`,size:`small`}),e.length,` 次工具调用`,o&&(0,B.jsx)(He,{state:o}),e.some(e=>e.state===`running`)&&(0,B.jsx)(He,{state:`running`})]}),(0,B.jsx)(`div`,{id:n,className:a?`computer-tool-list`:void 0,hidden:a&&!r,children:e.map(e=>(0,B.jsx)(Ge,{className:`computer-tool`,onToggle:a?void 0:e=>i(e.currentTarget.open),label:e.activity?.label??`工具调用`,meta:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(He,{state:e.state}),e.activity?.durationMs!==void 0&&(0,B.jsx)(`span`,{children:K(e.activity.durationMs)})]}),children:(0,B.jsx)(X,{text:e.body,onFile:t})},e.id))})]})}function Je({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r,rewind:i,onFile:a}){let o=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),s=new Map,c=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),l=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&c.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&s.set(t.activity.turnId,t.id);let u=e.filter(({activity:e,body:t})=>e?.kind!==`commentary`||!c.has(JSON.stringify([e.turnId,e.itemId]))&&!l.has(JSON.stringify([e.turnId,t])));return(0,B.jsx)(`div`,{className:`computer-messages`,children:Ke(u).map(e=>{if(Array.isArray(e))return(0,B.jsx)(qe,{calls:e,onFile:a},e[0].id);let c=e.activity;if(e.role===`system`)return(0,B.jsx)(q,{children:e.body},e.id);if(c?.kind===`turn`)return s.has(c.turnId)?null:(0,B.jsx)(J,{message:e},e.id);if(e.role===`user`)return(0,B.jsx)(We,{message:e,rewind:i,onFile:a,images:n&&(e.attachments??e.images)?.length?(0,B.jsx)(G,{images:e.attachments??e.images,url:t=>n(t,!!e.attachments)}):null,status:e.queue&&r?r(e):Y[e.state]&&(0,B.jsx)(he,{label:Y[e.state],state:e.state})},e.id);let l=c?.kind===`answer`&&s.get(c.turnId)===e.id?o.get(c.turnId):void 0;return(0,B.jsxs)(z.Fragment,{children:[l&&(0,B.jsx)(J,{message:l}),(0,B.jsx)(`article`,{className:`computer-agent-message ${c?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,B.jsx)(`div`,{className:`markdown`,children:(0,B.jsx)(me,{onFile:a,children:e.body})})})]},e.id)})})}function Ye({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){let[i,a]=(0,z.useState)(n),[o,c]=(0,z.useState)(!!n),l=`其他回答`,u=(0,z.useRef)(null),d=(0,z.useCallback)(e=>{if(!u.current)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.font=getComputedStyle(e).font;let n=Math.max(...(i||`${l}…`).split(`
8
+ `).map(e=>t.measureText(e).width));u.current.style.setProperty(`--reply-width`,`${Math.ceil(n+(o?52:26))}px`)},[i,o,l]),f=R(i,d);return(0,B.jsxs)(`form`,{ref:u,className:`inline-reply${o?` active`:``}`,onFocus:()=>c(!0),onBlur:e=>{!i&&!e.currentTarget.contains(e.relatedTarget)&&c(!1)},onSubmit:n=>{n.preventDefault(),!e&&i.trim()&&t(i.trim()).then(e=>{e&&a(``)})},children:[(0,B.jsx)(`textarea`,{ref:f,rows:1,"aria-label":`自定义回答`,placeholder:r??`${l}…`,value:i,disabled:e,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),!e&&i.trim()&&t.currentTarget.form?.requestSubmit())}}),o&&(0,B.jsx)(`button`,{className:`inline-reply-send`,type:`submit`,disabled:e||!i.trim(),"aria-label":`发送${l}`,title:`发送${l}`,children:(0,B.jsx)(s,{name:`send`,size:`small`})})]})}function Xe({question:t,session:n,request:r,refresh:i}){let[a,l]=(0,z.useState)({}),[u,d]=(0,z.useState)({}),[f,m]=(0,z.useState)(``),[h,g]=(0,z.useState)(!1),[y,b]=(0,z.useState)(!1),[x,S]=(0,z.useState)(``),C=(0,z.useRef)(null),w=(0,z.useRef)(!1),T=(0,z.useRef)(void 0);(0,z.useEffect)(()=>{if(t.state!==`pending`||w.current||!C.current)return;let e=!1,i=()=>{if(!e||document.visibilityState!==`visible`||!C.current)return;let i=C.current.getBoundingClientRect();i.bottom>0&&i.top<innerHeight&&r(`web/local-agent-sessions/${n}/questions/${t.id}/presented`,v({ok:c()}),{method:`POST`}).then(()=>{w.current=!0}).catch(e=>m(p(e)))},a=new IntersectionObserver(t=>{e=t.some(e=>e.isIntersecting),i()});return a.observe(C.current),document.addEventListener(`visibilitychange`,i),()=>{a.disconnect(),document.removeEventListener(`visibilitychange`,i)}},[t.id,t.state,n,r]);async function E(a){let s=JSON.stringify(a);T.current?.fingerprint!==s&&(T.current={fingerprint:s,value:{...a,id:e()}}),g(!0),m(``);try{return await r(`web/local-agent-sessions/${n}/questions/${t.id}/answers`,o(),{method:`POST`,body:T.current.value}),T.current=void 0,i(),!0}catch(e){return m(p(e)),!1}finally{g(!1)}}let[D,O]=(0,z.useState)(Date.now);(0,z.useEffect)(()=>{if(!t.approval||t.state!==`pending`||t.autoApproveAt==null)return;O(Date.now());let e=setInterval(()=>O(Date.now()),1e3);return()=>clearInterval(e)},[t.approval,t.state,t.autoApproveAt]);let k=t.autoApprove!==!1&&t.autoApproveAt!=null?Math.max(0,Math.ceil((t.autoApproveAt-D)/1e3)):null,A=t.response,j=t.state===`answered`,ee=[`expired`,`cancelled`].includes(t.state),te=[`human_routed`,`failed`,`handled`].includes(t.submissionState??``)&&!j,M=t.state===`pending`&&(!A||te),ne=t.kind===`plan`,N=t.actions?.find(e=>e.id===A?.actionId),re=ee?`已过期`:t.state===`uncertain`||t.submissionState===`uncertain`?`需核对`:j?ne?N?.label??`已处理`:t.approval?A?.decision===!0?`已允许`:A?.decision===!1?`已拒绝`:`已处理`:N?N.label:A?``:`已回答`:te?`请重新提交`:A?`正在提交`:``,P=ee||A?.decision===!1||te?`close`:j?`check`:`clock`,F=t.questions.length>1||t.questions.some(e=>e.multiSelect),ie=(e=a)=>E({body:t.questions.length===1?e[t.questions[0].id]||(u[t.questions[0].id]??[]).join(`、`):JSON.stringify(e),...t.kind||t.questions.some(e=>e.multiSelect)?{answers:e}:{},...t.questions.some(e=>e.multiSelect)?{selections:u}:{}});return(0,B.jsxs)(`div`,{className:`native-question ${ne?`native-plan`:``}`,ref:C,children:[ne?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:`native-plan-heading`,children:[(0,B.jsx)(s,{name:`file`,size:`small`}),(0,B.jsx)(`span`,{children:`实施计划`})]}),M?(0,B.jsx)(`div`,{className:`native-plan-content markdown`,children:(0,B.jsx)(me,{children:t.plan??``})}):(0,B.jsxs)(`details`,{className:`native-plan-history markdown`,children:[(0,B.jsx)(`summary`,{children:`查看计划`}),(0,B.jsx)(me,{children:t.plan??``})]}),M&&(0,B.jsxs)(B.Fragment,{children:[!y&&(0,B.jsx)(`div`,{className:`question-actions native-plan-actions ${t.actions&&t.actions.length>3?`native-plan-actions-expanded`:``}`,children:t.actions?.map(e=>(0,B.jsx)(`button`,{type:`button`,disabled:h,title:e.description,className:e.id===`implement`?`primary`:``,onClick:()=>e.id===`revise`?b(!0):void E({body:e.label,actionId:e.id}),children:e.label},e.id))}),!y&&t.actions?.find(e=>e.id===`implement`)?.description&&(0,B.jsxs)(`small`,{className:`native-plan-note muted`,children:[`开始实施:`,t.actions.find(e=>e.id===`implement`).description]}),y&&(0,B.jsxs)(`form`,{className:`native-plan-feedback`,onSubmit:e=>{e.preventDefault(),E({body:x,actionId:`revise`})},children:[(0,B.jsxs)(`label`,{children:[`修改意见`,(0,B.jsx)(`textarea`,{autoFocus:!0,value:x,onChange:e=>S(e.target.value),placeholder:`说明希望调整的部分,Agent 将修改后再次请求确认`})]}),(0,B.jsxs)(`div`,{className:`question-actions native-plan-feedback-actions`,children:[(0,B.jsx)(`button`,{className:`primary`,disabled:h||!x.trim(),children:`提交修改意见`}),(0,B.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>b(!1),children:`返回计划`})]})]})]}),!M&&A?.actionId===`revise`&&A.answers.feedback&&(0,B.jsx)(`div`,{className:`question-response`,children:A.answers.feedback})]}):t.approval?(0,B.jsxs)(`div`,{className:`native-approval-row`,children:[(0,B.jsx)(Ge,{className:`native-approval-details`,label:t.questions.map(e=>e.text.split(`
9
+ `).filter(Boolean).slice(0,2).join(` · `)).join(` · `),children:(0,B.jsx)(`pre`,{children:t.questions.map(e=>e.text).join(`
10
+
11
+ `)})}),M?(0,B.jsxs)(`div`,{className:`native-approval-options`,children:[(0,B.jsxs)(`button`,{type:`button`,className:`primary`,disabled:h,"aria-label":`允许`,title:k===null?void 0:`倒计时结束后自动允许本次操作`,onClick:()=>void E({body:`允许`,decision:!0}),children:[`允许`,k!==null&&(0,B.jsxs)(`span`,{"aria-hidden":`true`,children:[`(`,k,`s)`]})]}),(0,B.jsx)(`button`,{type:`button`,disabled:h,onClick:()=>void E({body:`拒绝`,decision:!1}),children:`拒绝`})]}):re&&(0,B.jsxs)(`small`,{className:`question-result`,children:[(0,B.jsx)(s,{name:P,size:`small`}),re]})]}):(0,B.jsxs)(B.Fragment,{children:[t.questions.map(e=>(0,B.jsxs)(`div`,{className:`native-question-part`,children:[(0,B.jsx)(`p`,{children:e.text}),M&&(0,B.jsx)(`div`,{className:`question-options ${Object.values(e.descriptions??{}).some(Boolean)?`question-options-described`:``}`,children:e.options.map(t=>(0,B.jsxs)(`button`,{type:`button`,disabled:h,"aria-pressed":e.multiSelect?u[e.id]?.includes(t)??!1:a[e.id]===t,onClick:()=>{if(e.multiSelect){d(n=>({...n,[e.id]:n[e.id]?.includes(t)?n[e.id].filter(e=>e!==t):[...n[e.id]??[],t]}));return}let n={...a,[e.id]:t};l(n),F||ie(n)},children:[(0,B.jsxs)(`span`,{className:`question-option-label`,children:[e.multiSelect&&(0,B.jsx)(`span`,{"aria-hidden":`true`,className:`question-check`,children:u[e.id]?.includes(t)&&(0,B.jsx)(s,{name:`check`,size:`small`})}),t]}),e.descriptions?.[t]&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`question-option-separator`,"aria-hidden":`true`,children:`|`}),(0,B.jsx)(`span`,{className:`question-option-description`,title:e.descriptions[t],children:e.descriptions[t]})]})]},t))}),e.freeText&&M&&(0,B.jsx)(Ye,{initialValue:e.initialValue,placeholder:e.placeholder,disabled:h,onSend:async t=>{let n={...a,[e.id]:t};return l(n),F?!0:ie(n)}}),M&&F&&a[e.id]&&!e.options.includes(a[e.id])&&(0,B.jsx)(`small`,{children:a[e.id]}),!M&&!t.approval&&(A?.answers[e.id]||A?.selections?.[e.id]?.length)&&(0,B.jsxs)(`div`,{className:`question-response`,children:[(0,B.jsx)(s,{name:j?`check`:`clock`,size:`small`}),(0,B.jsx)(`span`,{children:[...A.selections?.[e.id]??[],A.answers[e.id]].filter(Boolean).join(`、`)})]})]},e.id)),M&&t.actions?.length&&(0,B.jsx)(`div`,{className:`question-actions`,children:t.actions.map(e=>(0,B.jsx)(`button`,{disabled:h,onClick:()=>void E({body:e.label,actionId:e.id}),children:e.label},e.id))}),M&&F&&(0,B.jsx)(`div`,{className:`question-actions`,children:(0,B.jsx)(`button`,{disabled:h||t.questions.some(e=>!a[e.id]?.trim()&&!u[e.id]?.length),onClick:()=>void ie(),children:`回答`})})]}),re&&(!t.approval||ne)&&(0,B.jsxs)(`small`,{className:`question-result`,children:[(0,B.jsx)(s,{name:P,size:`small`}),re]}),(0,B.jsx)(_,{error:!0,children:f})]})}function Ze({session:t,active:n,commands:r,request:i,refresh:a,onError:o}){let[c,l]=(0,z.useState)(!1),[u,d]=(0,z.useState)(),f=(0,z.useRef)(void 0),m=r.find(e=>e.id===u?.id)??u,h=c||m&&[`queued`,`running`].includes(m.state)||r.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state));if(!n&&!h)return null;async function g(){if(!h){f.current??=e(),l(!0),o(``);try{let e=await i(`web/local-agent-sessions/${t}/commands`,P,{method:`POST`,body:{id:f.current,kind:`stop`}});d(e),f.current=void 0,a()}catch(e){o(p(e))}finally{l(!1)}}}return(0,B.jsxs)(`button`,{type:`button`,className:`message-stop`,"aria-label":h?`正在停止`:`停止当前轮`,title:h?`正在停止`:`停止当前轮`,disabled:!!h,onClick:()=>void g(),children:[(0,B.jsx)(`span`,{className:`message-stop-ring`,"aria-hidden":`true`}),(0,B.jsx)(s,{name:`stop`,size:`small`})]})}var Z={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`,ultra:`极致`,none:`无`,off:`关闭`};function Q({id:e,label:t,current:n,options:r,disabled:i,onSelect:a}){let o=r.find(e=>e.value===n);return(0,B.jsx)(b,{id:`${e}-menu`,triggerId:e,placement:`top`,className:`composer-menu composer-choice`,label:`选择${t}`,disabled:i,routeKey:n,trigger:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{title:`${t}:${o?.label??n}`,children:o?.shortLabel??o?.label??n}),(0,B.jsx)(s,{name:`chevronDown`,size:`small`})]}),children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`div`,{className:`composer-menu-heading`,children:t}),r.map(t=>(0,B.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),a(t.value)},children:[(0,B.jsxs)(`span`,{className:`composer-option-copy`,children:[(0,B.jsx)(`span`,{children:t.label}),t.description&&(0,B.jsx)(`small`,{children:t.description})]}),t.value===n&&(0,B.jsx)(s,{name:`check`,size:`small`})]},t.value))]})})}function Qe({session:e,models:t,busy:n,available:r,online:i,commands:a,controls:o,draft:c,onInsert:l,onConfig:u}){let[d,f]=(0,z.useState)(!1);(0,z.useEffect)(()=>{/^[/$]([^\s]*)$/.exec(c)?f(!0):f(!1)},[c]);let p=e.config.model??e.effectiveConfig?.model,m=t.find(e=>e.id===p||e.resolvedModel===p)??(e.config.model?void 0:t.find(e=>e.isDefault)),h=n||!r,g=e.provider===`claude`,_=e.provider===`cursor`,v=e.provider===`pi`,y=o??ee(e.provider),x=m?.effortLabel??`思考强度`,S=e=>m?.effortLabel?e:Z[e]??e,C=e.appliedRevision===e.revision?e.effectiveConfig?.mode:void 0,w=t.find(e=>e.isDefault)?.id??(e.config.model?null:e.effectiveConfig?.model),T=t.find(e=>e.id===w)?.name??w,E=e=>g?e.replace(/^Claude\s+/,``):e,D=[{value:``,label:T?`默认 · ${T}`:t.length?`默认模型`:`模型未获取`,shortLabel:T?E(T):t.length?`默认模型`:`模型`},...t.map(e=>({value:e.id,label:e.name,shortLabel:E(e.name)}))];e.config.model&&!t.some(t=>t.id===e.config.model)&&D.push({value:e.config.model,label:e.config.model,shortLabel:E(e.config.model)});let O=m?.id===e.effectiveConfig?.model?e.effectiveConfig?.effort:m?.defaultEffort,k=[{value:``,label:O?`默认 · ${S(O)}`:`默认${x}`,shortLabel:O?S(O):m?.effortLabel??`强度`},...(m?.efforts??[]).map(e=>({value:e,label:S(e)}))];return e.config.effort&&!k.some(t=>t.value===e.config.effort)&&k.push({value:e.config.effort,label:S(e.config.effort)}),(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(b,{id:`session-commands`,triggerId:`session-command-trigger`,label:`命令与 Skills`,placement:`top`,className:`composer-menu composer-commands`,routeKey:e.id,trigger:(0,B.jsx)(s,{name:`command`,size:`small`}),open:d,onOpenChange:f,focusFirst:!1,disabled:h||!i,children:e=>(0,B.jsxs)(B.Fragment,{children:[[...a].sort((e,t)=>e.name.localeCompare(t.name,`en`)).map(t=>(0,B.jsx)(`button`,{type:`button`,role:`menuitem`,title:[t.description,t.path].filter(Boolean).join(`
12
+ `),onClick:()=>{e(),l(t)},children:(0,B.jsxs)(`span`,{className:`composer-command-row`,children:[(0,B.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,B.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!a.length&&(0,B.jsx)(`div`,{className:`composer-menu-heading`,children:`尚未获取命令`})]})}),(0,B.jsx)(Q,{id:`session-model`,label:`模型`,current:e.config.model??``,options:D,disabled:h,onSelect:n=>{let r=t.find(e=>e.id===n);u({...e.config,model:n||null,..._?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(!_&&!v&&e.provider!==`opencode`||(m?.efforts.length??0)>0||!!e.config.effort)&&(0,B.jsx)(Q,{id:`session-effort`,label:x,current:e.config.effort??``,options:k,disabled:h,onSelect:t=>u({...e.config,effort:t||null})}),m?.options?.map(t=>(0,B.jsx)(Q,{id:`session-option-${t.id}`,label:t.name,current:e.config.options?.[t.id]??``,options:[{value:``,label:`默认 · ${t.choices.find(e=>e.value===t.defaultValue)?.label??t.defaultValue}`},...t.choices],disabled:h,onSelect:n=>{let r={...e.config.options};n?r[t.id]=n:delete r[t.id],u({...e.config,options:r})}},t.id)),y.map(t=>(0,B.jsx)(Q,{id:t.key===`mode`&&!g?`session-mode`:`session-permission`,label:t.label,current:t.key===`mode`?C??e.config.mode??t.defaultValue:e.config.permission,options:t.choices,disabled:h,onSelect:n=>u(t.key===`mode`?{...e.config,mode:n||void 0}:{...e.config,permission:n})},t.key))]})}var $e=(0,z.lazy)(()=>le(()=>import(`./TerminalPane-DDJO3cDO.js`),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url)),et=v({ok:c()}),tt={idle:`空闲`,working:`工作中`,waiting:`等待回答`,queued:`等待执行`,uncertain:`需要核对`,human:`人工处理`,offered:`待本地接收`,accepted:`本地已接手`,human_routed:`未送达本地`,pending:`待投递`,sent:`已发送`,succeeded:`已完成`,running:`进行中`,failed:`失败`};function nt({navigate:e,memberId:t}){let{request:n,projectId:r}=A(),i=(0,z.useCallback)(e=>n(`web/local-agent-settings`,N,{signal:e}),[n]),a=C(i,3e4);return(0,z.useEffect)(()=>{let e=()=>void a.reload();return window.addEventListener(`teammy:local-access`,e),()=>window.removeEventListener(`teammy:local-access`,e)},[a.reload]),a.error?(0,B.jsx)(_,{error:!0,children:a.error}):a.data?(0,B.jsx)(rt,{localAvailable:a.data.accessible,navigate:e,memberId:t},`${r}/${t}`):null}function rt({localAvailable:n,navigate:r,memberId:a}){let c=A(),u=S(),d=t(c.projectId,a,`computer-selection`),f=t(c.projectId,a,`computer-drafts`),h=u?.get(d),[g,v]=(0,z.useState)(()=>new Set),[y,x]=(0,z.useState)(()=>({project:c.projectId,directory:new URLSearchParams(location.search).get(`directory`)??h?.directory??``,session:new URLSearchParams(location.search).get(`session`)??(new URLSearchParams(location.search).has(`terminal`)?``:h?.session??``),terminal:new URLSearchParams(location.search).get(`terminal`)??(new URLSearchParams(location.search).has(`session`)?``:h?.terminal??``)})),[w,E]=(0,z.useState)(``),[j,ee]=(0,z.useState)(!1),[M,N]=(0,z.useState)(!1),[P,F]=(0,z.useState)(()=>u?.get(f)??{}),oe=P[y.session]??``,le=e=>F(t=>({...t,[y.session]:typeof e==`function`?e(t[y.session]??``):e}));(0,z.useEffect)(()=>{u?.set(f,P)},[u,f,P]);let[I,pe]=(0,z.useState)(``),[me,L]=(0,z.useState)(!1),[R,ye]=(0,z.useState)(`codex`),[Se,V]=(0,z.useState)(!1),[Ce,we]=(0,z.useState)(``),[Ee,De]=(0,z.useState)(),[Oe,Ae]=(0,z.useState)(Date.now);(0,z.useEffect)(()=>{let e=setInterval(()=>Ae(Date.now()),6e4);return()=>clearInterval(e)},[]);let H=(0,z.useRef)(null),Ne=(0,z.useRef)(!0),Pe=(0,z.useRef)(void 0),Ie=(0,z.useRef)(e()),Le=(0,z.useCallback)(async e=>n?(await c.request(`web/local-agent-computers`,ie,{signal:e})).computers.map(e=>({...e,project:c.projectId})):[],[c,n]),U=C(Le,3e3),Re=(U.data??[]).flatMap(e=>e.directories.map(t=>({c:e,d:t,label:ue(U.data??[],e,t)}))).sort((e,t)=>e.label.localeCompare(t.label)),W=U.data?.find(e=>e.project===y.project&&e.directories.some(e=>e.id===y.directory)),G=Te(c.projectId,n),Ve=G.terminals.find(e=>e.id===y.terminal),He=(0,z.useRef)(Ve);Ve&&(He.current=Ve);let We=Ve??(He.current?.id===y.terminal?He.current:void 0),Ge=W?.directories.find(e=>e.id===y.directory),K=U.data?.find(e=>e.directories.some(e=>e.id===Ce))??W,q=K?.directories.find(e=>e.id===Ce)??Ge;D(y.project);let J=(0,z.useCallback)((e,t,n)=>D(y.project).request(e,t,n),[y.project]),Y=Be(y.session,y.project,J),Ke=(0,z.useCallback)(e=>y.session&&n?J(`web/local-agent-sessions/${y.session}`,se,{signal:e}):Promise.resolve(null),[J,y.session,n]),X=C(Ke,15e3),[qe,Ye]=(0,z.useState)(),Z=qe?.session.id===y.session&&(!X.data||qe.cursor>=X.data.cursor)?qe:X.data;(0,z.useEffect)(()=>{if(!y.session||!n)return;let e=new EventSource(i(`/api/v1/projects/${encodeURIComponent(y.project)}/web/local-agent-sessions/${encodeURIComponent(y.session)}/events`)),t=!0;return e.addEventListener(`snapshot`,e=>{try{let n=se.parse(JSON.parse(e.data));t&&Ye(e=>e?.session.id===n.session.id&&e.cursor>n.cursor?e:n)}catch(e){E(p(e))}}),()=>{t=!1,e.close()}},[y.project,y.session,n]),(0,z.useEffect)(()=>{Ne.current=!0},[y.project,y.session]),(0,z.useEffect)(()=>{Ne.current&&H.current&&(H.current.scrollTop=H.current.scrollHeight)},[Z?.cursor,Z?.messages.length]);let Q=Z?.session.id===y.session?Z.session:void 0;function nt({path:e,line:t}){let n=e.split(`/`).at(-1),r=/\/\.workspace\/\.teammy-attachments\/([0-9a-f-]{36})\/[^/]+$/i.exec(e);if(!y.terminal&&Q&&r){let e=Z?.messages.flatMap(e=>e.attachments??[]).find(e=>e.id===r[1]);De({...e,name:e?.name??n,line:t,url:ze(y.project,Q.id,r[1],!0)});return}let a=y.terminal?We?.directory:Q?.executionDirectory??Q?.directory;if(!a)return;let o=i(`/api/v1/projects/${encodeURIComponent(y.project)}/web/local-agents/${encodeURIComponent(a)}/file?${new URLSearchParams({path:e})}`),s=Me(n);De({name:n,line:t,url:o,previewUrl:o+(s.startsWith(`text/`)?`&view=text`:s?``:`&view=info`)})}let rt=W?.capabilities.includes(`local-sessions-v1`),$=(e,t,n=``,r=``)=>{De(void 0),x({project:e,directory:t,session:n,terminal:r}),u?.set(d,{directory:t,session:n,terminal:r}),L(!1),V(!1),E(``);let i=new URL(location.href);i.searchParams.delete(`view`),i.searchParams.delete(`section`),i.searchParams.set(`directory`,t),r?i.searchParams.set(`terminal`,r):i.searchParams.delete(`terminal`),n?i.searchParams.set(`session`,n):i.searchParams.delete(`session`),e===c.projectId&&history.replaceState(null,``,i)};(0,z.useEffect)(()=>{let e=U.data?.find(e=>e.sessions.some(e=>e.id===y.session))??U.data?.find(e=>e.directories.length);if(!y.directory&&e?.directories.length){let t=e.directories[0],n=e.sessions.find(e=>e.id===y.session);$(e.project,n?.directory??t.id,n?.id??t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id)}},[U.data]),(0,z.useEffect)(()=>{if(!Q)return;let e=()=>{document.visibilityState===`visible`&&J(`web/local-agent-sessions/${Q.id}/read`,et,{method:`POST`}).catch(e=>E(p(e)))};return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Q?.id,Z?.messages.at(-1)?.seq,J]);async function it(e){ee(!0),E(``);try{await e(),await Promise.all([X.reload(),U.reload()])}catch(e){E(p(e))}finally{ee(!1)}}function at(e,t){return it(async()=>{if(await c.request(`web/local-agent-sessions/${e.id}/metadata`,ae,{method:`PUT`,body:{expectedRevision:e.metadataRevision,...t}}),t.hidden&&y.session===e.id){let t=W?.sessions.find(t=>t.directory===e.directory&&t.id!==e.id&&!t.hidden);$(y.project,e.directory,t?.id)}})}function ot(e){let t=new URLSearchParams({tab:`directories`,directory:e,session:y.session});r(`/projects/${c.projectId}/settings?${t}`)}function st(t=y.directory){let n=U.data?.find(e=>e.directories.some(e=>e.id===t))??W,r=n?.directories.find(e=>e.id===t)??n?.directories[0];!r||!n?N(!0):(Ie.current=e(),we(r.id),L(!0),ye(r.provider),E(``))}let[ct,lt]=(0,z.useState)(null);(0,z.useEffect)(()=>lt(null),[Q?.id]);let ut=W?.catalogs.find(e=>e.provider===(Q?.provider??`codex`)&&(Q?.cwd?e.cwd===Q.cwd:e.directory===(Q?.executionDirectory??Q?.directory))),dt=ut?.commands??[],ft=ut?.models??W?.providers.find(e=>e.id===Q?.provider)?.models??(Q?.provider===`codex`?W?.models??[]:[]),pt=ft.find(e=>e.id===(Q?.config.model??Q?.effectiveConfig?.model)||!!e.resolvedModel&&e.resolvedModel===(Q?.config.model??Q?.effectiveConfig?.model))??(Q?.config.model?void 0:ft.find(e=>e.isDefault)),mt=!!W?.capabilities.includes(`local-agent-attachments-v1`),ht=!!pt?.images&&!!W?.capabilities.includes(`local-agent-images-v1`),gt=Q?.state===`working`&&!Z?.commands.some(e=>e.kind===`stop`&&[`queued`,`running`].includes(e.state)),_t=Q?.provider===`cursor`&&W?.capabilities.includes(`local-agent-steer-v1`),vt=!W?.capabilities.includes(`local-agent-steer-v1`)&&(Q?.provider===`cursor`||Q?.provider===`claude`);function yt(t){let n=oe.trim();if(!Q||!n&&!Y.files.length)return;let r=Y.files.map(e=>e.id),i=ht?Y.files.filter(e=>e.mimeType!==`application/octet-stream`).map(e=>e.id):[],a=ct?.path&&n.startsWith(`$${ct.name}`)?[{name:ct.name,path:ct.path}]:void 0,s=JSON.stringify({session:Q.id,body:n,skills:a,attachments:r,images:i,delivery:t});Pe.current?.fingerprint!==s&&(Pe.current={fingerprint:s,id:e()});let c=Pe.current;it(async()=>{await J(`web/local-agent-sessions/${Q.id}/messages`,o(),{method:`POST`,body:{id:c.id,body:n,delivery:t,...i.length?{images:i}:{},...r.length?{attachments:r}:{},...a?{skills:a}:{}}}),le(e=>e.trim()===n?``:e),lt(null),Y.clear(),Pe.current===c&&(Pe.current=void 0)})}return(0,B.jsxs)(_e,{className:`computers-layout`,testId:`computers-page`,label:`本地会话`,tree:!0,navigation:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(O,{title:`电脑`}),(0,B.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":`目录与会话`,onKeyDown:be,children:Re.map(({c:e,d:t,label:n})=>{let r=`${e.project}/${t.id}`,i=!g.has(r);return(0,B.jsxs)(`div`,{role:`none`,children:[(0,B.jsxs)(`div`,{className:`computer-tree-row`,role:`none`,children:[(0,B.jsxs)(k,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":i,style:{"--tree-level":1},leading:(0,B.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,B.jsx)(s,{name:`chevron`,size:`small`})}),onClick:()=>{y.directory!==t.id&&$(e.project,t.id,t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id),v(e=>{let t=new Set(e);return i?t.add(r):t.delete(r),t})},children:[(0,B.jsx)(s,{name:`files`}),(0,B.jsx)(`span`,{className:`tree-name`,title:n,children:n})]}),(0,B.jsx)(m,{icon:`plus`,label:`新建会话:${n}`,className:`computer-tree-action`,onClick:()=>st(t.id)})]}),i&&(0,B.jsxs)(`div`,{role:`group`,children:[G.terminals.filter(e=>e.directory===t.id).map(n=>(0,B.jsx)(`div`,{className:`computer-tree-row computer-session-row computer-terminal-row`,role:`none`,children:(0,B.jsxs)(k,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":y.terminal===n.id,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>$(e.project,t.id,``,n.id),children:[(0,B.jsx)(s,{name:`command`}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.createdAt,children:n.state===`exited`?`已退出`:ke(n.createdAt,Oe)})]})]})},n.id)),e.sessions.filter(e=>e.directory===t.id).map(n=>(0,B.jsxs)(`div`,{className:`computer-tree-row computer-session-row`,role:`none`,children:[(0,B.jsxs)(k,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":y.session===n.id&&y.project===e.project,style:{"--tree-level":2},leading:(0,B.jsx)(`span`,{className:`tree-chevron`,children:(0,B.jsx)(`span`,{className:`assistant-message-dot ${n.unread?`unread`:``}`})}),title:`${n.title} · ${de[n.provider]}`,onClick:()=>$(e.project,t.id,n.id),children:[(0,B.jsx)(ne,{provider:n.provider}),(0,B.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,B.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,B.jsx)(`time`,{dateTime:n.updatedAt,title:new Date(n.updatedAt).toLocaleString(),children:ke(n.updatedAt,Oe)})]})]}),(0,B.jsx)(m,{icon:`link`,className:`computer-tree-action computer-session-pin${n.pinned?` pinned`:``}`,label:`${n.pinned?`取消自动接单`:`开启自动接单`}:${n.title}`,"aria-pressed":n.pinned,tooltip:n.pinned?`取消自动接单`:`开启自动接单`,disabled:j||n.archived,onClick:()=>void at(n,{pinned:!n.pinned})}),n.archived?(0,B.jsx)(`span`,{title:`已归档`,role:`img`,"aria-label":`已归档`,children:(0,B.jsx)(s,{name:`archive`,size:`small`})}):n.state!==`idle`&&(0,B.jsx)(he,{state:n.state,label:tt[n.state]??n.state})]},n.id))]})]},t.id)})}),(0,B.jsx)(_,{error:!0,children:U.error})]}),children:[M&&(0,B.jsx)(te,{onClose:()=>N(!1)}),Se&&K&&q&&(0,B.jsx)(je,{directory:q.id,provider:q.provider,providers:K.providers.map(e=>e.id),sessions:K.sessions,request:J,onClose:()=>V(!1),onImport:e=>{$(y.project,e.directory,e.id),U.reload()}}),me&&q&&(0,B.jsx)(l,{id:`computer-new-session`,title:`新建会话`,onClose:()=>L(!1),children:(0,B.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:t=>{t.preventDefault(),it(async()=>{if(R===`terminal`){let t=Ie.current;await G.request({type:`create`,id:t,directory:q.id,title:I.trim(),cols:100,rows:28}),Ie.current=e(),pe(``),$(y.project,q.id,``,t);return}let t=await J(`web/local-agents/${q.id}/sessions`,ae,{method:`POST`,body:{id:Ie.current,title:I,provider:R}});Ie.current=e(),L(!1),pe(``),$(y.project,q.id,t.id)})},children:[Re.length>1?(0,B.jsx)(fe,{title:`执行目录`,children:(0,B.jsx)(`select`,{"aria-label":`执行目录`,disabled:j,value:q.id,onChange:e=>{we(e.target.value),ye(Re.find(({d:t})=>t.id===e.target.value)?.d.provider??`codex`)},children:Re.map(({d:e,label:t})=>(0,B.jsx)(`option`,{value:e.id,children:t},e.id))})}):(0,B.jsxs)(`p`,{className:`muted computer-create-scope`,children:[`目录:`,q.name]}),(0,B.jsxs)(`label`,{children:[`会话名称`,(0,B.jsx)(`input`,{autoFocus:!0,required:!0,disabled:j,placeholder:`会话名称`,value:I,onChange:e=>pe(e.target.value)})]}),(0,B.jsx)(ce,{label:`会话类型`,value:R,onChange:ye,disabled:j,providers:re.options.filter(e=>e===`codex`||(e===`claude`?K?.capabilities.includes(`local-agent-providers-v1`):K?.providers.some(t=>t.id===e))),terminal:G.directories.includes(q.id)}),R===`terminal`&&(0,B.jsx)(`p`,{className:`muted computer-create-scope`,children:`在此目录启动本机 Shell,使用本机用户权限。`}),K?.providers.find(e=>e.id===R)?.error&&(0,B.jsx)(_,{children:K.providers.find(e=>e.id===R).error}),(0,B.jsx)(_,{error:!0,children:w}),(0,B.jsxs)(`div`,{className:`computer-create-options`,children:[R!==`terminal`&&(0,B.jsx)(`button`,{type:`button`,disabled:!K?.online||!K.capabilities.includes(`local-agent-history-v1`),onClick:()=>{L(!1),V(!0)},children:`导入历史会话`}),(0,B.jsx)(`button`,{type:`button`,onClick:()=>{L(!1),N(!0)},children:`接入目录`}),(0,B.jsx)(`button`,{className:`primary`,disabled:j||!I.trim()||(R===`terminal`?!G.directories.includes(q.id):!rt),children:`创建`})]})]})}),Ee&&(0,B.jsx)(Fe,{file:Ee,onClose:()=>De(void 0)},Ee.url),y.terminal?We?(0,B.jsx)(z.Suspense,{fallback:(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{title:We.title}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:`正在打开终端…`})]}),children:(0,B.jsx)($e,{terminal:We,onFile:nt,connection:G,onClosed:()=>$(y.project,y.directory)},We.id)}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{title:`终端`}),(0,B.jsx)(`div`,{className:`assistant-empty`,children:G.connected?`终端已结束或电脑已重启,请新建终端。`:`正在连接终端…`})]}):Ge?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{title:Q?(0,B.jsx)(xe,{title:Q.title,busy:j,onSave:e=>at(Q,{title:e})},Q.id):(0,B.jsx)(`h2`,{children:Ge.name}),actions:(0,B.jsx)(B.Fragment,{children:(0,B.jsx)(b,{id:`computer-session-menu`,triggerId:`computer-session-actions`,label:`会话操作`,trigger:(0,B.jsx)(s,{name:`more`}),className:`computer-create-menu`,routeKey:Q?.id??``,disabled:!Q,children:e=>(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`button`,{role:`menuitem`,disabled:j,onClick:()=>{e(),Q&&at(Q,{hidden:!0})},children:`隐藏会话`}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),ot(Ge.id)},children:`连接专用群`}),(0,B.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),ot(Ge.id)},children:`执行位置`})]})})})}),!rt&&(0,B.jsx)(_,{children:`升级客户端后可使用多个会话和网页对话。`}),(0,B.jsxs)(ge,{ref:H,onScroll:e=>{let t=e.currentTarget;Ne.current=t.scrollHeight-t.scrollTop-t.clientHeight<96},"aria-label":`本地会话记录`,children:[(0,B.jsx)(Je,{onFile:nt,messages:Q?Z.messages:[],rewind:Q?{session:Q.id,available:!!Z?.canRewind&&Q.state===`idle`&&!Q.archived,expectedLastMessage:Z?.messages.at(-1)?.id??``,commands:Z?.commands??[],request:J,refresh:X.reload}:void 0,imageUrl:(e,t)=>ze(y.project,Q.id,e,t),renderQueue:e=>(0,B.jsx)(Ue,{message:e}),renderQuestion:e=>(0,B.jsx)(Xe,{question:e,session:Q.id,request:J,refresh:X.reload})}),!Z?.messages.length&&(0,B.jsx)(`div`,{className:`assistant-empty`,children:Q?.resumeSession?`已接入原生会话,发送消息继续。`:`在当前目录开始一段对话。`})]}),Z?.commands.filter(e=>e.state!==`succeeded`&&![`diff`,`history`,`rewind`].includes(e.kind)&&!(e.kind===`stop`&&[`queued`,`running`].includes(e.state))).slice(-3).map(e=>(0,B.jsxs)(`p`,{className:`computer-control-status`,role:`status`,children:[e.kind===`stop`?`停止`:e.kind,` · `,tt[e.state]??e.state,e.error?`:${e.error}`:``]},e.id)),(0,B.jsx)(_,{error:!0,children:w||X.error||Q?.error}),Q&&(0,B.jsx)(ve,{value:oe,onChange:le,label:`向本地 Agent 发送消息`,sendLabel:gt?_t?`中断并发送`:vt?`加入队列`:`插话`:`发送`,onQueue:[`working`,`waiting`].includes(Q.state)&&W?.capabilities.includes(`local-agent-queue-v1`)?()=>yt(`queue`):void 0,placeholder:Q.archived?`会话已归档`:`输入消息…`,disabled:Q.archived||!rt,sendDisabled:j||Y.busy||Y.failed||Y.count>0&&!mt||Z?.commands.some(e=>e.kind===`rewind`&&[`queued`,`running`,`uncertain`].includes(e.state)),attachments:(0,B.jsxs)(B.Fragment,{children:[Y.preview(j),Y.files.some(e=>e.mimeType!==`application/octet-stream`)&&!ht&&(0,B.jsx)(_,{children:`当前模型将通过本地文件路径接收图片。`})]}),hasAttachments:Y.count>0,onFiles:mt&&!j?e=>void Y.add(e):void 0,beforeSend:(0,B.jsx)(Ze,{session:Q.id,active:[`working`,`waiting`].includes(Q.state),commands:Z?.commands??[],request:J,refresh:X.reload,onError:E},Q.id),actions:(0,B.jsxs)(B.Fragment,{children:[mt?Y.picker(j||!rt,ht):ht?(0,B.jsx)(`span`,{title:`更新开发机客户端后可添加附件`,children:(0,B.jsx)(`button`,{type:`button`,className:`icon-button`,disabled:!0,"aria-label":`更新开发机客户端后可添加附件`,children:(0,B.jsx)(s,{name:`attachment`,size:`small`})})}):null,(0,B.jsx)(Qe,{session:Q,models:ft,busy:j,available:!!rt,online:!!W?.online,commands:dt,controls:ut?.controls,draft:oe,onInsert:e=>{lt(e.kind===`skill`?e:null),le(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{it(()=>J(`web/local-agent-sessions/${Q.id}/settings`,ae,{method:`PUT`,body:{expectedRevision:Q.revision,config:e}}))}})]}),onSubmit:()=>yt(`auto`)})]}):(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(T,{title:`本地会话`}),(0,B.jsxs)(`div`,{className:`assistant-empty`,children:[`尚未登记本地执行目录。`,(0,B.jsx)(`button`,{onClick:()=>N(!0),children:`接入目录`})]})]})]})}export{nt as Computers,xe as t};
@@ -0,0 +1 @@
1
+ main#main:has(.conversation-layout){height:var(--pane-height);padding:0;overflow:hidden}.assistant-layout{height:100%;min-height:0;overflow:hidden}.assistant-list{flex-direction:column;min-height:0;display:flex;overflow:hidden}.assistant-message-scroll,.assistant-transcript{scrollbar-gutter:stable;scrollbar-width:thin;flex:1;min-height:0;overflow-y:auto}.assistant-list-status{margin:20px var(--pane-gutter);color:var(--color-muted);font-size:var(--text-sm)}.assistant-message-item{isolation:isolate;gap:var(--space-2);width:100%;padding:20px var(--pane-gutter);text-align:left;color:var(--color-text);background:0 0;border:0;border-radius:0;align-items:center;display:flex;position:relative}.assistant-message-item:hover{background:0 0}.assistant-message-item:is(:hover,.selected):before{content:"";inset:var(--space-1) var(--pane-gap);z-index:-1;border-radius:var(--radius-sm);background:var(--color-hover);position:absolute}.assistant-message-item.selected:before{background:var(--color-soft)}.assistant-message-item.archived{color:var(--color-muted)}.assistant-message-item.archived strong{font-weight:400}.assistant-list-actions{align-items:center;gap:6px;display:flex}.assistant-new-chat{width:32px;height:32px;min-height:32px;color:var(--brand-orange);background:var(--color-accent-soft);padding:6px}.assistant-new-chat .icon{width:20px;height:20px}.assistant-new-chat:after{top:calc(100% + 6px);bottom:auto}.assistant-message-copy{flex-direction:column;flex:1;gap:6px;min-width:0;display:flex}.assistant-message-copy>.selection-content{width:fit-content;max-width:calc(100% + 2 * var(--space-2));padding:5px var(--space-2);margin:-5px calc(-1 * var(--space-2));color:var(--color-text);display:block;overflow:visible}.assistant-message-item.archived .selection-content{color:inherit}.assistant-message-copy .selection-inner{min-width:0;display:block}.assistant-message-copy .selection-inner strong{display:block}.assistant-message-copy strong,.assistant-message-copy>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.assistant-message-copy strong{font-size:var(--text-base);font-weight:600}.assistant-message-copy>span,.assistant-message-copy time{font-size:var(--text-xs);color:var(--color-muted)}.assistant-message-dot{border-radius:50%;flex:0 0 7px;width:7px;height:7px}.assistant-message-dot.unread{background:var(--brand-orange)}.assistant-thread{flex-direction:column;min-width:0;min-height:0;display:flex;overflow:hidden}.assistant-transcript{padding:28px clamp(20px,4vw,64px)}.assistant-matter-state{border-bottom:1px solid var(--color-line);color:var(--color-muted);font-size:var(--text-xs);overflow-wrap:anywhere;padding:10px 28px;line-height:1.6}.assistant-bubble-row{margin:0 0 24px;display:flex}.assistant-bubble-row.mine{justify-content:flex-end}.assistant-bubble{border-radius:4px var(--radius-lg) var(--radius-lg);background:var(--color-soft);overflow-wrap:anywhere;min-width:100px;max-width:min(88%,800px);padding:14px 18px}.assistant-bubble-row.mine .assistant-bubble{background:var(--color-accent-soft);border-radius:var(--radius-lg) 4px var(--radius-lg) var(--radius-lg)}.assistant-bubble-meta{font-size:var(--text-xs);color:var(--color-muted);align-items:baseline;gap:16px;margin-bottom:8px;display:flex}.assistant-debug-reply{font-size:var(--text-xs);background:var(--color-surface);margin-top:12px;padding:4px 10px}.assistant-bubble .markdown>:first-child{margin-top:0}.assistant-bubble .markdown>:last-child{margin-bottom:0}.assistant-bubble .markdown{font-size:var(--text-base);line-height:1.75}.assistant-bubble .markdown h1,.assistant-bubble .markdown h2{font-size:18px}.assistant-bubble .markdown h3,.assistant-bubble .markdown h4,.assistant-bubble .markdown h5,.assistant-bubble .markdown h6{font-size:var(--text-base)}.assistant-bubble .markdown :is(h1,h2,h3,h4,h5,h6){margin:18px 0 8px;line-height:1.5}.assistant-bubble .markdown :is(p,ul,ol){margin:10px 0}.assistant-bubble .markdown :is(ul,ol){padding-left:1.5em}.assistant-bubble .markdown li+li{margin-top:4px}.assistant-bubble .markdown li>:is(ul,ol){margin:4px 0}.assistant-bubble pre{max-width:100%;overflow-x:auto}.assistant-reply-hint{font-size:var(--text-xs);color:var(--color-muted);margin:0 28px 10px;line-height:1.7}.assistant-empty{height:100%;min-height:240px;color:var(--color-muted);flex-direction:column;justify-content:center;align-items:center;gap:20px;display:flex}.assistant-empty .mascot{width:176px;height:176px}.assistant-empty p{margin:0}.assistant-archived{color:var(--color-muted);font-size:var(--text-sm);justify-content:center;align-items:center;gap:8px;padding:24px;display:flex}.assistant-thread>.notice{margin:0 28px 12px}.assistant-typing{gap:5px;padding:8px 0;display:inline-flex}.assistant-typing i{background:var(--color-muted);border-radius:50%;width:5px;height:5px;animation:1.4s infinite assistant-pulse}.assistant-typing i:nth-child(2){animation-delay:.15s}.assistant-typing i:nth-child(3){animation-delay:.3s}@keyframes assistant-pulse{0%,70%,to{opacity:.35}35%{opacity:1}}@media (prefers-reduced-motion:reduce){.assistant-typing i{animation:none}}@media (width<=900px){.assistant-message-item{padding-block:var(--space-4)}.assistant-reply-hint{margin:0 16px 10px}.assistant-bubble{max-width:96%}}@media (width<=680px){.assistant-transcript{padding:16px 10px}.assistant-reply-hint{margin:0 8px 10px}}.assistant-participants{text-overflow:ellipsis;white-space:nowrap;min-width:0;max-width:45%;color:var(--color-muted);font-size:var(--text-sm);margin-left:16px;overflow:hidden}@media (width<=680px){.conversation-layout{grid-template-rows:minmax(130px,26dvh) minmax(0,1fr)}}.conversation-status{background:var(--color-muted);vertical-align:middle;border-radius:50%;flex:0 0 6px;width:6px;height:6px;display:inline-block}.conversation-status.state-online,.conversation-status:is(.state-working,.state-running,.state-waiting,.state-queued,.state-offered,.state-pending){background:var(--brand-orange)}.conversation-status:is(.state-failed,.state-human_routed,.state-uncertain){background:var(--color-danger)}.conversation-status.state-offline{opacity:.45}.topic-preview{font-size:var(--text-xs);color:var(--color-muted);display:block;overflow:hidden}.conversation-system-message{text-align:center;color:var(--color-muted);font-size:var(--text-xs);margin:16px 0;line-height:1.6}.conversation-post.assistant-bubble{background:0 0;max-width:none;padding:0}.conversation-post .assistant-bubble-meta{justify-content:space-between}.channel-layout .assistant-transcript{padding-inline:var(--pane-gutter)}.channel-layout .assistant-turn+.assistant-turn{margin-block-start:var(--space-6)}.channel-layout .assistant-message-item{padding-block:var(--space-3)}.channel-layout .assistant-message-copy{gap:4px}
@@ -1 +1 @@
1
- import{w as e}from"./Dropdown-nwEutrew.js";import{O as t}from"./index-DDxaaPSE.js";var n=e();function r({navigation:e,children:r,className:i=``,tree:a=!1,label:o,testId:s}){return(0,n.jsx)(t,{className:`assistant-layout conversation-layout ${i}`,"data-testid":s,navigation:(0,n.jsx)(`aside`,{className:`assistant-list ${a?`file-tree-pane`:``}`,"aria-label":`${o}列表`,children:e}),children:(0,n.jsx)(`section`,{className:`assistant-thread`,"aria-label":o,children:r})})}function i({mine:e=!1,author:t,time:r,children:i,className:a=``,ref:o,...s}){return(0,n.jsx)(`div`,{...s,ref:o,className:`assistant-bubble-row ${e?`mine`:``} ${a}`,children:(0,n.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,n.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`span`,{children:t}),r&&(0,n.jsx)(`time`,{dateTime:r,children:new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),i]})})}function a({label:e,state:t=`idle`}){return(0,n.jsx)(`span`,{className:`conversation-status state-${t}`,role:`img`,"aria-label":e,title:e})}function o({author:e,time:t,children:r}){return(0,n.jsxs)(`article`,{className:`conversation-post assistant-bubble`,children:[(0,n.jsxs)(`header`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`strong`,{children:e}),t&&(0,n.jsx)(`time`,{dateTime:t,children:new Date(t).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),r]})}function s({title:e,actions:t}){return(0,n.jsxs)(`header`,{className:`assistant-thread-heading`,children:[(0,n.jsx)(`div`,{className:`conversation-title`,children:e}),t]})}function c({ref:e,...t}){return(0,n.jsx)(`div`,{role:`log`,"aria-live":`polite`,...t,ref:e,className:`assistant-transcript`})}export{c as a,o as i,s as n,a as o,r,i as t};
1
+ import{T as e}from"./Dropdown-D625ln2m.js";import{N as t}from"./index-DjMoKD7A.js";var n=e();function r({navigation:e,children:r,className:i=``,tree:a=!1,label:o,testId:s}){return(0,n.jsx)(t,{className:`assistant-layout conversation-layout ${i}`,"data-testid":s,navigation:(0,n.jsx)(`aside`,{className:`assistant-list ${a?`file-tree-pane`:``}`,"aria-label":`${o}列表`,children:e}),children:(0,n.jsx)(`section`,{className:`assistant-thread`,"aria-label":o,children:r})})}function i({mine:e=!1,author:t,time:r,children:i,className:a=``,ref:o,...s}){return(0,n.jsx)(`div`,{...s,ref:o,className:`assistant-bubble-row ${e?`mine`:``} ${a}`,children:(0,n.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,n.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`span`,{children:t}),r&&(0,n.jsx)(`time`,{dateTime:r,children:new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),i]})})}function a({label:e,state:t=`idle`}){return(0,n.jsx)(`span`,{className:`conversation-status state-${t}`,role:`img`,"aria-label":e,title:e})}function o({author:e,time:t,children:r}){return(0,n.jsxs)(`article`,{className:`conversation-post assistant-bubble`,children:[(0,n.jsxs)(`header`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`strong`,{children:e}),t&&(0,n.jsx)(`time`,{dateTime:t,children:new Date(t).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),r]})}function s({ref:e,...t}){return(0,n.jsx)(`div`,{role:`log`,"aria-live":`polite`,...t,ref:e,className:`assistant-transcript`})}export{a,s as i,r as n,o as r,i as t};
@@ -0,0 +1 @@
1
+ import{C as e,Et as t,Ot as n,St as r,T as i,Tt as a,_ as o,a as s,b as c,c as l,d as u,k as d,l as f,m as p,p as m,r as h,s as g,t as _,x as v,xt as y,y as b}from"./Dropdown-D625ln2m.js";import{B as x,R as S,V as C}from"./index-DjMoKD7A.js";import{t as w}from"./project-links-DI2fBvjw.js";import"./file-links-CVbLZSaw.js";var T=t(((e,t)=>{t.exports=typeof process==`object`&&{}.NODE_DEBUG&&/\bsemver\b/i.test({}.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),E=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),D=t(((e,t)=>{var{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=E(),a=T();e=t.exports={};var o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),O=t(((e,t)=>{var n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),k=t(((e,t)=>{var n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),A=t(((e,t)=>{var n=T(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=E(),{safeRe:a,t:o}=D(),s=O(),{compareIdentifiers:c}=k(),l=(e,t)=>{let n=t.split(`.`);if(n.length>e.length)return!1;for(let t=0;t<n.length;t++)if(c(e[t],n[t])!==0)return!1;return!0};t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);this.prerelease=l[4]?l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e!==i)return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];if(n===!1&&(r=[t]),l(this.prerelease,t)){let e=this.prerelease[t.split(`.`).length];isNaN(e)&&(this.prerelease=r)}else this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),j=t(((e,t)=>{var n=A();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),M=y(),N=n(j(),1),P=i();function F({className:e=``,...t}){return(0,P.jsx)(`button`,{type:`button`,...t,className:`pill-control ${e}`})}function I({className:e=``,...t}){return(0,P.jsx)(_,{...t,className:`pill-menu ${e}`})}var L=[{value:`time`,label:`按时间`,icon:`clock`},{value:`owner`,label:`按用户`,icon:`members`}];function R(e){e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),history.pushState(null,``,e.currentTarget.href),window.dispatchEvent(new PopStateEvent(`popstate`)))}var z=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function B({members:t,project:n,memberId:i}){let{request:a,projectId:o}=S(),c=`teammy-board-mine:${i}:${o}`,[u,d]=(0,M.useState)(()=>{try{return localStorage.getItem(c)===`true`}catch{return!1}}),f=`teammy-board-order:${i}:${o}`,[g,_]=(0,M.useState)(()=>{try{return localStorage.getItem(f)===`owner`?`owner`:`time`}catch{return`time`}}),y=L.find(e=>e.value===g),b=(0,M.useCallback)(e=>a(`tasks`,x,{signal:e}),[a]),C=v(b,3e3,e(o,`tasks`)),[w,T]=(0,M.useState)(),[E,D]=(0,M.useState)(!1),[O,k]=(0,M.useState)(Date.now);(0,M.useEffect)(()=>{let e=setInterval(()=>k(Date.now()),6e4);return()=>clearInterval(e)},[]);let A=C.data,j=A?.tasks.filter(e=>!u||e.owner===i)??[],N=new Set(t.map(e=>e.id));return(0,P.jsxs)(`div`,{className:`task-board`,children:[(0,P.jsx)(p,{title:n?.projectName.trim()?`${n.projectName.trim()}|工作看板`:`工作看板`,description:n?.description.trim()||``,children:(0,P.jsxs)(`div`,{className:`task-board-brand`,children:[(0,P.jsx)(`a`,{className:`task-board-home`,"data-testid":`home-link`,href:r(`/projects`),onClick:R,"aria-label":`项目主页`,"data-tooltip":`项目主页`,children:(0,P.jsx)(h,{})}),t.some(e=>e.id===i&&e.bound)&&(0,P.jsx)(V,{memberId:i})]})}),(0,P.jsxs)(`div`,{className:`task-board-toolbar`,role:`group`,"aria-label":`看板筛选与排序`,children:[(0,P.jsxs)(F,{"aria-pressed":u,"data-testid":`task-board-mine`,onClick:()=>{let e=!u;d(e),D(!1);try{localStorage.setItem(c,String(e))}catch{}},children:[(0,P.jsx)(l,{name:u?`enable`:`account`,size:`small`}),`只看我的`]}),(0,P.jsx)(I,{id:`task-board-sort-menu`,triggerId:`task-board-sort`,label:`任务排序:${y.label}`,routeKey:g,trigger:(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(l,{name:y.icon,size:`small`}),(0,P.jsx)(`span`,{children:y.label}),(0,P.jsx)(l,{name:`chevronDown`,size:`small`})]}),children:e=>L.map(t=>(0,P.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),_(t.value),D(!1);try{localStorage.setItem(f,t.value)}catch{}},children:[(0,P.jsx)(l,{name:t.icon,size:`small`}),(0,P.jsx)(`span`,{children:t.label}),g===t.value&&(0,P.jsx)(l,{name:`check`,size:`small`})]},t.value))})]}),(0,P.jsx)(m,{error:!0,children:C.error}),(0,P.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:z.filter(e=>e.status!==null||j.some(e=>e.status===null)).map(e=>{let t=j.filter(t=>t.status===e.status);t.sort((t,n)=>(g===`owner`?t.owner.localeCompare(n.owner,`en`,{numeric:!0}):0)||(e.status===`completed`?n.statusSince.localeCompare(t.statusSince):t.statusSince.localeCompare(n.statusSince))||t.id.localeCompare(n.id));let n=e.status===`completed`&&!E?t.slice(0,5):t;return(0,P.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,P.jsxs)(`h2`,{children:[(0,P.jsx)(`span`,{className:`lane-dot`}),e.label,(0,P.jsx)(s,{children:A?t.length:`—`})]}),(0,P.jsxs)(`div`,{className:`task-lane-content`,children:[t.length?n.map(e=>(0,P.jsx)(H,{task:e,memberIds:N,now:O,onEdit:()=>T(e),onSaved:()=>void C.reload()},e.id)):(0,P.jsx)(`p`,{className:`task-lane-empty`,children:C.error&&!A?`读取失败`:A?`暂无任务`:`读取中…`}),e.status===`completed`&&t.length>5&&(0,P.jsxs)(`button`,{type:`button`,className:`task-lane-expand`,"aria-expanded":E,onClick:()=>D(!E),children:[(0,P.jsx)(l,{name:E?`chevronUp`:`chevronDown`,size:`small`}),E?`收起`:`展开其余 ${t.length-5} 项`]})]})]},e.label)})}),w&&(0,P.jsx)(G,{task:w,onClose:()=>T(void 0),onSaved:()=>{T(void 0),C.reload()}},w.id)]})}function V({memberId:e}){let{api:t,projectId:n}=S(),r=v(t.devices,!0),i=b();if(!r.data||!i.data||r.error||i.error)return null;let o=(0,N.default)(i.data.version),[s]=r.data.devices.filter(t=>t.memberId===e&&t.bound).map(e=>(0,N.default)(e.status?.clientVersion)).filter(e=>e!==null).sort((e,t)=>e.compare(t));if(!s||!o||s.compare(o)>=0)return null;let c=i.data.versions.filter(e=>{let t=(0,N.default)(e);return t&&(!t.prerelease.length||e===o.raw)&&t.compare(s)>0&&t.compare(o)<=0}).length;return(0,P.jsx)(`p`,{className:`task-board-update${c>5?` overdue`:``}`,children:(0,P.jsxs)(`a`,{href:a(n,`settings/client-maintenance.md`,`#升级与修复`),onClick:R,children:[(0,P.jsx)(l,{name:`attention`,size:`small`}),(0,P.jsxs)(`span`,{children:[`客户端待更新 `,s.raw,` → `,o.raw,c>10&&`,您完全不更新是吗:(`]})]})})}function H({task:e,memberIds:t,onEdit:n,onSaved:i,now:a}){let{projectId:s,request:u}=S(),p=c(),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(``);async function y(){if(!h){g(!0),v(``);try{await u(`tasks/${e.id}/correction`,C,{method:`PATCH`,signal:p,body:{needsConfirmation:!1,expectedRevision:e.revision}}),p.aborted||i()}catch(e){p.aborted||v(d(e))}finally{g(!1)}}}return(0,P.jsxs)(`details`,{className:`task-card`,"data-testid":`task-card`,"data-task-id":e.id,"data-owner":e.owner,"data-status":e.status??`unknown`,children:[(0,P.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,P.jsx)(`h3`,{children:e.title}),(0,P.jsxs)(`span`,{className:`task-card-meta`,children:[(0,P.jsx)(`small`,{title:e.owner,children:e.owner}),e.needsConfirmation&&(0,P.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,P.jsx)(l,{name:`attention`,size:`small`}),`需要确认`]}),e.status!==`completed`&&(0,P.jsx)(U,{since:e.statusSince,now:a})]})]}),(0,P.jsx)(f,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${e.title}`,"data-testid":`task-correct`,disabled:h,onClick:n}),(0,P.jsxs)(`div`,{className:`task-card-details`,children:[(0,P.jsx)(`h4`,{children:`目标`}),(0,P.jsx)(`p`,{children:e.goal?(0,P.jsx)(W,{value:e.goal,memberIds:t}):`目标未明确`}),(0,P.jsx)(`h4`,{children:`当前进展`}),(0,P.jsx)(`p`,{className:`task-progress`,children:(0,P.jsx)(W,{value:e.progress,memberIds:t})}),(0,P.jsx)(`div`,{className:`task-card-sources`,children:e.sources.map(t=>(0,P.jsxs)(`a`,{"data-testid":`task-source`,href:r(t.kind===`material`?`/projects/${s}/materials?id=${t.materialId}&revision=${t.revision}`:w(s,e.owner,t.path)),children:[(0,P.jsx)(l,{name:`file`,size:`small`}),(0,P.jsx)(`span`,{children:t.path})]},t.path))}),e.syncedAt&&(0,P.jsxs)(`small`,{children:[`资料同步于 `,(0,P.jsx)(o,{value:e.syncedAt})]}),e.needsConfirmation&&(0,P.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,P.jsx)(m,{error:!0,children:_}),(0,P.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:h,onClick:()=>void y(),children:h?`正在保存…`:`保存`})]})]})]})}function U({since:e,now:t}){let n=Math.max(0,t-Date.parse(e)),r=Math.floor(n/6e4),i=r<1?`刚刚`:r<60?`${r} 分钟`:r<1440?`${Math.floor(r/60)} 小时`:`${Math.floor(r/1440)} 天`;return(0,P.jsxs)(`span`,{className:`task-age${n>6048e5?` stale`:``}`,"data-testid":`task-age`,title:`进入当前状态:${new Date(e).toLocaleString(`zh-CN`)}`,"aria-label":`当前状态停留 ${i}`,children:[(0,P.jsx)(l,{name:`clock`,size:`small`}),i]})}function W({value:e,memberIds:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,P.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function G({task:e,onClose:t,onSaved:n}){let{request:r}=S(),i=c(),[a,o]=(0,M.useState)(e.title),[s,l]=(0,M.useState)(e.status??``),[f,p]=(0,M.useState)(e.goal??``),[h,_]=(0,M.useState)(e.progress),[v,y]=(0,M.useState)(!1),[b,x]=(0,M.useState)(``),w={...a===e.title?{}:{title:a},...s===(e.status??``)?{}:{status:s||null},...f===(e.goal??``)?{}:{goal:f||null},...h===e.progress?{}:{progress:h},...e.needsConfirmation?{needsConfirmation:!1}:{}};async function T(){if(!v&&Object.keys(w).length){y(!0),x(``);try{await r(`tasks/${e.id}/correction`,C,{method:`PATCH`,signal:i,body:{...w,expectedRevision:e.revision}}),i.aborted||n()}catch(e){i.aborted||x(d(e))}finally{y(!1)}}}return(0,P.jsx)(u,{id:`task-correction`,title:`纠正任务`,onClose:t,children:(0,P.jsxs)(`form`,{className:`stack`,"aria-busy":v,onSubmit:e=>{e.preventDefault(),T()},children:[(0,P.jsx)(g,{id:`task-title`,label:`标题`,children:(0,P.jsx)(`input`,{value:a,required:!0,onChange:e=>o(e.target.value)})}),(0,P.jsxs)(`fieldset`,{className:`task-status-field`,disabled:v,children:[(0,P.jsx)(`legend`,{children:`状态`}),(0,P.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:z.filter(e=>e.status!==null).map(e=>(0,P.jsxs)(`label`,{className:`task-status-choice`,children:[(0,P.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:s===e.status,onChange:()=>l(e.status)}),(0,P.jsx)(`span`,{children:e.label})]},e.status))}),(0,P.jsx)(`small`,{children:`待验收:任务成果已提交,等待验收或最终确认。`})]}),(0,P.jsx)(g,{id:`task-goal`,label:`目标`,children:(0,P.jsx)(`textarea`,{value:f,onChange:e=>p(e.target.value)})}),(0,P.jsx)(g,{id:`task-progress`,label:`当前进展`,children:(0,P.jsx)(`textarea`,{value:h,onChange:e=>_(e.target.value)})}),(0,P.jsx)(m,{error:!0,children:b}),(0,P.jsx)(`div`,{className:`row wrap`,children:(0,P.jsx)(`button`,{type:`submit`,className:`primary`,disabled:v||!Object.keys(w).length,"data-testid":`task-correction-save`,children:`保存`})})]})})}function K({members:e,config:t,memberId:n}){return(0,P.jsx)(B,{members:e,project:t,memberId:n})}export{K as Dashboard};
@@ -0,0 +1 @@
1
+ .task-board{min-width:0}.task-board .page-header{grid-template-columns:minmax(0,1fr) fit-content(50%);align-items:start;display:grid}.task-board .page-header p{overflow-wrap:anywhere}.task-board-brand{flex-direction:column;align-items:flex-end;display:flex}.task-board-update a{align-items:center;gap:var(--space-1);color:inherit;text-decoration:none;display:flex}.task-board-update a:hover{color:var(--color-text)}.task-board-update.overdue a{color:var(--brand-orange)}@media (width<=680px){.task-board .page-header{row-gap:0}.task-board-brand{display:contents}.task-board-update{grid-column:1/-1;justify-self:end}}.task-board-home{height:calc(var(--text-title) * 1.35);border-radius:var(--radius-sm);align-items:center;display:flex}.task-board-home:hover{opacity:.75}.task-board-home .brand img{width:auto;height:calc(var(--text-title) * 1.04)}.task-board-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:24px;display:flex}.task-board-lanes{grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));align-items:start;gap:24px;margin-bottom:32px;display:grid}.task-lane{min-width:0}.task-lane h2{font-size:var(--text-base);border-bottom:1px solid var(--color-line);align-items:center;gap:10px;padding:0 0 16px;font-weight:600;display:flex}.task-lane .count{margin-left:auto}.task-lane-content{flex-direction:column;gap:12px;padding-top:16px;display:flex}.lane-dot{border:1.5px solid var(--color-muted);border-radius:50%;width:8px;height:8px}.task-lane[data-stage=in_progress] .lane-dot{border-color:var(--brand-orange);background:var(--brand-orange)}.task-lane[data-stage=in_review] .lane-dot{border-color:var(--brand-black);background:var(--brand-black)}.task-lane[data-stage=completed] .lane-dot{border-color:var(--color-muted);background:var(--color-muted)}.task-lane-empty{font-size:var(--text-xs);color:var(--color-muted);padding:44px 0}.task-card{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);overflow-wrap:anywhere;min-width:0;position:relative}.task-card>.task-card-heading{border-radius:inherit;padding:16px;list-style:none;position:static}.task-age{white-space:nowrap;color:var(--color-muted);font-size:var(--text-xs);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;font-weight:400;display:inline-flex}.task-age .icon{width:13px;height:13px}.task-age.stale{color:var(--brand-orange)}.task-lane-expand{min-height:32px;color:var(--color-muted);font-size:var(--text-xs);background:0 0;border:0;justify-content:center;align-items:center;gap:6px;display:flex}.task-card-heading::-webkit-details-marker{display:none}.task-card-heading:hover{background:var(--color-soft)}.task-card[open]>.task-card-heading h3{padding-right:32px}.task-card-meta{align-items:center;gap:8px;margin-top:8px;display:flex}.task-card-meta>small{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.task-confirmation{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:var(--brand-orange);font-size:calc(var(--text-xs) - 1px);flex-shrink:0;align-items:center;gap:3px;padding:0 4px;font-weight:400;line-height:18px;display:inline-flex}.task-confirmation .icon{width:12px;height:12px}.task-card-confirm{flex-direction:column;align-items:flex-end;gap:8px;margin-top:16px;display:flex}.task-card-confirm button{min-height:32px;font-size:var(--text-xs);padding:4px 12px}.task-status-field legend{font-size:var(--text-sm);margin-bottom:8px;font-weight:600}.task-status-options{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.task-status-choice{cursor:pointer;position:relative}.task-status-choice input{opacity:0;width:100%;height:100%;min-height:0;cursor:inherit;position:absolute;inset:0}.task-status-choice span{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);min-height:36px;font-size:var(--text-sm);justify-content:center;align-items:center;font-weight:550;display:flex}.task-status-choice:hover span{background:var(--color-soft)}.task-status-choice input:checked+span{border-color:var(--brand-black);background:var(--brand-black);color:var(--color-on-dark)}.task-status-choice input:focus-visible+span{border-color:var(--color-input-focus)}.task-status-choice input:disabled+span{opacity:.45;cursor:default}.task-card-heading h3{font-size:var(--text-base);font-weight:650;line-height:1.55}.task-card-edit{opacity:0;pointer-events:none;position:absolute;top:10px;right:8px}.task-card[open]:hover>.task-card-edit{opacity:1;pointer-events:auto}.task-card[open]:has(:focus-visible)>.task-card-edit{opacity:1;pointer-events:auto}.task-progress{font-size:var(--text-sm);white-space:pre-wrap;line-height:1.85}.task-card small{color:var(--color-muted);font-size:var(--text-xs)}.task-card-details{padding:0 16px 16px}.task-card-details h4{font-size:var(--text-xs);margin:16px 0 4px;font-weight:600}.task-card-details p{font-size:var(--text-sm);margin:0}.task-card-sources{flex-direction:column;align-items:flex-start;gap:8px;margin:16px 0;display:flex}.task-card-sources a{text-align:left;overflow-wrap:anywhere;max-width:100%;font-size:var(--text-xs);min-height:28px;color:var(--color-muted);justify-content:flex-start;gap:8px;padding:4px 0;text-decoration:none;display:inline-flex}.task-card-sources a:hover{color:var(--color-link);text-decoration:underline}.task-mention{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:inherit;padding:0 2px}button.pill-control,.pill-menu .dropdown-trigger{background:var(--color-soft);min-height:30px;color:var(--color-muted);font-size:var(--text-xs);white-space:nowrap;border:1px solid #0000;border-radius:999px;justify-content:center;align-items:center;gap:6px;padding:5px 11px;font-weight:500;line-height:18px;display:inline-flex}button.pill-control:hover,button.pill-control[aria-pressed=true],.pill-menu .dropdown-trigger:hover,.pill-menu .dropdown-trigger[aria-expanded=true]{background:var(--color-hover);color:var(--color-text)}button.pill-control[aria-pressed=true]{border-color:var(--color-line)}.pill-radio-group{flex-wrap:wrap;gap:6px;display:flex}.pill-radio-group .pill-control{padding:5px 8px}button.pill-control[aria-checked=true]{background:var(--color-accent-soft);color:var(--color-text);border-color:var(--color-danger-line)}button.pill-control[role=radio]:focus-visible{border-color:var(--color-input-focus);outline:none}.pill-radio-group .agent-logo{width:17px;height:17px;padding:0}.pill-control>.icon,.pill-menu .dropdown-trigger>.icon{flex-shrink:0;width:14px;height:14px}.pill-menu .dropdown-menu{border-radius:var(--radius-md);width:168px;padding:5px;top:calc(100% + 6px)}.pill-menu .dropdown-menu [role=menuitem]{min-height:32px;font-size:var(--text-xs);gap:8px;padding:8px;font-weight:500}