@teammy/server 0.2.10 → 0.2.11

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 (35) hide show
  1. package/dist/main.js +545 -191
  2. package/dist/web/assets/Assistant-DLyxXHVH.js +1 -0
  3. package/dist/web/assets/Computers-BNJeNZB6.css +1 -0
  4. package/dist/web/assets/Computers-Bnq9vurA.js +7 -0
  5. package/dist/web/assets/{Conversation-DiVjLVVt.js → Conversation-BFT_YU_m.js} +1 -1
  6. package/dist/web/assets/Dashboard-zwfEddfm.js +1 -0
  7. package/dist/web/assets/Dropdown-BVXg1qjS.js +55 -0
  8. package/dist/web/assets/Files-DvZhUMI0.js +1 -0
  9. package/dist/web/assets/{Help-CDOqVRjJ.js → Help-D2wGnf7L.js} +72 -44
  10. package/dist/web/assets/{HtmlPreview-BzvYKdju.js → HtmlPreview-C3railXk.js} +1 -1
  11. package/dist/web/assets/{Markdown-zJQlHcvy.js → Markdown-DwIYP3W0.js} +4 -4
  12. package/dist/web/assets/MessageComposer-Ddu83TIm.js +1 -0
  13. package/dist/web/assets/MessageComposer-e3g3t5jX.css +1 -0
  14. package/dist/web/assets/ResourceLibrary-CwHQw2pF.js +6 -0
  15. package/dist/web/assets/{TerminalPane-GU69G9Ak.js → TerminalPane-D6QTLh_P.js} +2 -2
  16. package/dist/web/assets/WorkspaceTree-DPnUT5Zj.js +1 -0
  17. package/dist/web/assets/{file-links-V3R--z0b.js → file-links-BcFN8P1K.js} +1 -1
  18. package/dist/web/assets/index-4y82i1SF.css +1 -0
  19. package/dist/web/assets/index-DbOamGWI.js +10 -0
  20. package/dist/web/downloads/teammy-inbox-skill.zip +0 -0
  21. package/dist/web/downloads/teammy-skill.zip +0 -0
  22. package/dist/web/index.html +3 -3
  23. package/package.json +1 -1
  24. package/dist/web/assets/Assistant-C9Zo5FN_.js +0 -1
  25. package/dist/web/assets/Computers-DNIWiHu4.js +0 -5
  26. package/dist/web/assets/Computers-XUdWIkZr.css +0 -1
  27. package/dist/web/assets/Dashboard-C6M9c0SB.js +0 -1
  28. package/dist/web/assets/Dropdown-BnYLBw2s.js +0 -55
  29. package/dist/web/assets/Files-CQcAEYH9.js +0 -1
  30. package/dist/web/assets/MessageComposer-CBI6RiJq.js +0 -1
  31. package/dist/web/assets/MessageComposer-CJGxkvML.css +0 -1
  32. package/dist/web/assets/ResourceLibrary-CEFCe7QW.js +0 -6
  33. package/dist/web/assets/WorkspaceTree-BhDZe1go.js +0 -1
  34. package/dist/web/assets/index-D9m13C7l.js +0 -12
  35. package/dist/web/assets/index-qX1GRw9I.css +0 -1
Binary file
@@ -12,9 +12,9 @@
12
12
  href="./assets/teammy-y-standard-dark-C4LRaRpE.svg"
13
13
  media="(prefers-color-scheme: dark)"
14
14
  />
15
- <script type="module" crossorigin src="./assets/index-D9m13C7l.js"></script>
16
- <link rel="modulepreload" crossorigin href="./assets/Dropdown-BnYLBw2s.js">
17
- <link rel="stylesheet" crossorigin href="./assets/index-qX1GRw9I.css">
15
+ <script type="module" crossorigin src="./assets/index-DbOamGWI.js"></script>
16
+ <link rel="modulepreload" crossorigin href="./assets/Dropdown-BVXg1qjS.js">
17
+ <link rel="stylesheet" crossorigin href="./assets/index-4y82i1SF.css">
18
18
  </head>
19
19
  <body>
20
20
  <div id="root" data-teammy-ui-version="11"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teammy/server",
3
- "version": "0.2.10",
3
+ "version": "0.2.11",
4
4
  "description": "The centralized Teammy collaboration hub server.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1 +0,0 @@
1
- import{C as e,D as t,E as n,S as r,_t as i,b as a,c as o,ct as s,d as c,f as l,ft as u,gt as d,l as f,nt as p,ot as m,rt as h,st as g,u as ee,ut as _,v as te,x as ne}from"./Dropdown-BnYLBw2s.js";import{S as v,T as re,c as ie,d as ae,f as oe,i as se,l as y,p as b,u as ce}from"./index-D9m13C7l.js";import{a as le,i as ue,n as de,r as fe,t as pe}from"./Conversation-DiVjLVVt.js";import{t as me}from"./Markdown-zJQlHcvy.js";import{t as he}from"./MessageComposer-CBI6RiJq.js";var x=d(),S=r(),ge=s({topics:p(s({id:_(),title:_(),summary:_(),author:_(),replies:g(),unread:h(),createdAt:_(),updatedAt:_(),delivery:s({available:h(),connected:h(),state:_(),error:_().nullable()})}))}),_e=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),C=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function w({me:r,mode:d=`messages`}){let{projectId:p,request:g}=re(),w=ne(),ye=a(p,r,`${d}-selection`),T=a(p,r,`${d}-drafts`),be=(0,x.useCallback)(e=>g(`agents/outbox`,oe,{signal:e}),[g]),E=te(be,3e3,a(p,r,`outbox`)),xe=(0,x.useCallback)(async e=>d===`messages`?g(`agents/chats`,ie,{signal:e}):{chats:(await g(`channels/topics`,ge,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[g,d]),D=te(xe,3e3,a(p,r,d,`chats`)),[O,Se]=(0,x.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??w?.get(ye)??``}),k=O.startsWith(`chat:`)?O.slice(5):``,A=!O||!!k,[j,M]=(0,x.useState)(()=>w?.get(a(p,r,`chat`,k))),N=j?.id===k?j:w?.get(a(p,r,`chat`,k)),P=D.data?.chats.find(e=>e.id===k),F=P&&`delivery`in P?P.delivery:void 0,[Ce,I]=(0,x.useState)(),[L,R]=(0,x.useState)(()=>w?.get(T)??{}),we=L[O]??``,Te=e=>R(t=>({...t,[O]:e})),[z,B]=(0,x.useState)(!1),[V,Ee]=(0,x.useState)(!1),[De,Oe]=(0,x.useState)(!1),[ke,H]=(0,x.useState)(!1),[U,Ae]=(0,x.useState)(``),[je,Me]=(0,x.useState)(``),Ne=(0,x.useRef)(t()),[Pe,W]=(0,x.useState)(``),[Fe,G]=(0,x.useState)(``),K=(0,x.useRef)(new Map),Ie=(0,x.useRef)(null),q=(0,x.useRef)(!0),J=(0,x.useRef)(O);J.current=O,(0,x.useEffect)(()=>{j&&w?.set(a(p,r,`chat`,j.id),j)},[w,p,r,j]),(0,x.useEffect)(()=>{w?.set(T,L)},[w,T,L]);function Y(e){J.current=e,Se(e),w?.set(ye,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=>d===`messages`&&e.box===`debug`).reverse(),Z=E.data?.messages.find(e=>e.id===(O===`debug`?Ce: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`&&g(`agents/outbox/${Z.id}/read`,b,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(n(e)))},[Z?.id,Z?.readAt,O,g,E.reload]),(0,x.useEffect)(()=>{O===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>g(`agents/outbox/${e}/read`,b,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(n(e)))},[O,Q,g,E.reload]),(0,x.useEffect)(()=>{if(G(``),!k)return;let t=!0,o=-1,c=!1,l=new AbortController,u=e=>{!t||e.id!==k||e.cursor<o||(o=e.cursor,c=!0,e.redirect?Y(`chat:${e.redirect}`):e.entry===`channel`&&d!==`channels`?location.replace(i(`/projects/${p}/channels?chat=${e.id}`)):(M(e),G(``)))};g(`agents/chats/${k}`,y,{signal:l.signal}).then(u).catch(i=>{t&&!l.signal.aborted&&(i instanceof e&&[401,403,404].includes(i.status)&&(w?.delete(a(p,r,`chat`,k)),M(e=>e?.id===k?void 0:e)),c||G(n(i)))});let f=e=>{let n=Number(e.lastEventId);return!t||!Number.isSafeInteger(n)||n<=o?!1:(o=n,!0)},m=new EventSource(i(`/api/v1/projects/${encodeURIComponent(p)}/agents/chats/${encodeURIComponent(k)}/events`));m.addEventListener(`snapshot`,e=>{if(t)try{u(y.parse(JSON.parse(e.data)))}catch(e){G(n(e))}}),m.onerror=()=>{t&&G(`对话连接中断,正在重新连接…`)},m.addEventListener(`context`,e=>{if(!f(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:o}:e)}),m.addEventListener(`message`,e=>{if(!f(e))return;let t=ce.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)}),m.addEventListener(`message_removed`,e=>{if(!f(e))return;let{id:t}=s({id:_()}).parse(JSON.parse(e.data));M(e=>e?.id===k?{...e,cursor:o,messages:e.messages.filter(e=>e.id!==t)}:e)}),m.addEventListener(`run`,e=>{if(!f(e))return;let t=ae.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`])m.addEventListener(e,t=>{if(!f(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()=>{t=!1,l.abort(),m.close()}},[p,k,r,g,w]),(0,x.useEffect)(()=>{if(!N||N.id!==k)return;let e=()=>{document.visibilityState===`visible`&&g(`agents/chats/${k}/read`,s({ok:h()}),{method:`POST`,body:{cursor:N.readCursor}}).then(()=>{D.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>W(n(e)))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[k,N?.readCursor,N?.kind,g]),(0,x.useEffect)(()=>{q.current&&Ie.current?.scrollIntoView({block:`end`})},[O,j?.messages,Z?.recipients,X.length]);function Le(){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 g(`agents/outbox/${e}/read`,b,{method:`POST`}),Le()}catch(e){W(n(e))}}async function Re(){if(!V){Ee(!0),W(``);try{let e=await g(`agents/chats`,y,{method:`POST`});M(e),await $(`chat:${e.id}`),D.reload()}catch(e){W(n(e))}finally{Ee(!1)}}}async function ze(e){e.preventDefault();let r=we.trim();if(!r||z||V)return;B(!0),W(``);let i=K.current.get(O);i&&i.text===r||(i={text:r,id:t()},K.current.set(O,i));try{if(A){let e=i.target??k;if(!e){let t=await g(`agents/chats`,y,{method:`POST`});e=t.id,i.target=e,K.current.set(`chat:${e}`,i),R(t=>({...t,[`chat:${e}`]:r})),J.current===O&&(M(t),Y(`chat:${e}`))}let t=await g(`agents/chats/${e}`,ae.extend({conversationId:_().optional()}),{method:`POST`,body:{text:r,requestId:i.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 g(`agents/outbox/${Z.id}/reply`,s({conversationId:_()}),{method:`POST`,body:{body:r,requestId:i.id}});Le(),J.current===O&&Y(`chat:${e.conversationId}`),D.reload(),I(void 0)}K.current.delete(O),i.target&&K.current.delete(`chat:${i.target}`),R(e=>({...e,[O]:``,...i.target?{[`chat:${i.target}`]:``}:{}}))}catch(e){W(n(e))}finally{B(!1)}}let Be=d===`channels`?ue:pe,Ve=A&&!N?.closed&&(d!==`channels`||!!k)||!!Z&&!Z.archivedAt,He=A&&!N&&(!!k||!D.data);return(0,S.jsxs)(fe,{className:d===`channels`?`channel-layout`:``,testId:`assistant-page`,label:A?`Tim对话`:`消息内容`,navigation:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`assistant-list-heading`,children:[(0,S.jsx)(`h1`,{children:d===`channels`?`频道`:`对话`}),(0,S.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,S.jsx)(f,{className:`assistant-new-chat`,icon:`clear`,label:`清除未读`,disabled:De,onClick:()=>{Oe(!0),W(``),g(`communication/read`,s({ok:m(!0)}),{method:`POST`,body:{scope:d}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([D.reload(),E.reload()])}).catch(e=>W(n(e))).finally(()=>Oe(!1))}}),(0,S.jsx)(f,{className:`assistant-new-chat`,icon:`plus`,label:d===`channels`?`发表话题`:`新建对话`,disabled:V,onClick:()=>d===`channels`?H(!0):void Re(),"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.jsx)(`span`,{className:`assistant-message-dot ${e.unread||d!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`}),(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})}),d===`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`}),` `,_e(e.updatedAt)]})]})]},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.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`}),(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)})]})]}),E.data?.messages.filter(e=>d===`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.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`}),(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`}),` `,_e(e.createdAt)]})]})]},e.id))]}),(0,S.jsx)(l,{error:!0,children:E.error||D.error})]}),children:[ke&&(0,S.jsxs)(c,{id:`new-topic`,title:`发表话题`,onClose:()=>H(!1),children:[(0,S.jsx)(he,{inset:!0,plain:!0,value:je,onChange:Me,label:`正文`,placeholder:`开始一个话题…`,sendLabel:`发表话题`,sendDisabled:z||!U.trim(),heading:(0,S.jsx)(`input`,{className:`topic-title`,"aria-label":`标题`,placeholder:`标题`,required:!0,value:U,onChange:e=>Ae(e.target.value)}),onSubmit:e=>{e.preventDefault(),B(!0),W(``),g(`channels/topics`,y,{method:`POST`,body:{id:Ne.current,title:U,body:je}}).then(e=>{M(e),Y(`chat:${e.id}`),H(!1),Ae(``),Me(``),Ne.current=t(),D.reload()}).catch(e=>W(n(e))).finally(()=>B(!1))}}),(0,S.jsx)(l,{error:!0,children:Pe})]}),(0,S.jsx)(de,{title:(0,S.jsx)(`h2`,{children:A?P?.title??N?.title??(k?`无标题`:`Tim`):O===`debug`?`运行提醒`:`项目消息`}),actions:(0,S.jsxs)(S.Fragment,{children:[d===`channels`&&k&&(0,S.jsx)(se,{conversation:k}),d!==`channels`&&N?.kind===`matter`&&(0,S.jsxs)(`span`,{className:`assistant-participants`,title:N.participants?.join(`、`),children:[N.visibility===`project`?`项目共享 · `:``,N.participants?.join(`、`)]}),d===`channels`&&F?.available&&(F.state===`web`||F.state===`cancelled`||!F.connected)&&(0,S.jsx)(f,{icon:`send`,label:`发布到企业微信频道`,disabled:z,onClick:()=>{B(!0),g(`channels/topics/${k}/publish`,u(),{method:`POST`}).then(()=>D.reload()).catch(e=>W(n(e))).finally(()=>B(!1))}})]})}),d===`channels`&&(0,S.jsx)(l,{error:!0,children:F?.error}),d!==`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)(le,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;q.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[A?He?(0,S.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,S.jsx)(ee,{}),(0,S.jsx)(`p`,{role:`status`,children:Fe||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)(Be,{mine:e.role===`user`&&e.author===r,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)(me,{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)(l,{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)(ve,{item:e,onReply:e.archivedAt?void 0:()=>{I(e.id),Te(``),W(``)}},e.id)):Z&&(0,S.jsx)(ve,{item:Z}),(0,S.jsx)(`div`,{ref:Ie})]}),(0,S.jsx)(l,{error:!0,children:Pe||(A?Fe:``)}),Ve?(0,S.jsx)(he,{value:we,onChange:Te,onSubmit:e=>void ze(e),disabled:V,sendDisabled:z||He,label:A?`向Tim提问`:`回复消息`}):O!==`debug`&&Z&&(0,S.jsxs)(`div`,{className:`assistant-archived`,children:[(0,S.jsx)(o,{name:`archive`}),`已归档`]})]})}function ve({item:e,onReply:t}){return(0,S.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,S.jsxs)(pe,{author:e.box===`debug`?`运行提醒`:`Tim`,time:e.createdAt,children:[(0,S.jsx)(`div`,{className:`markdown`,children:(0,S.jsx)(me,{children:e.body})}),t&&(0,S.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:`回复`})]})})}export{w as Assistant};
@@ -1,5 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./TerminalPane-GU69G9Ak.js","./Dropdown-BnYLBw2s.js","./Conversation-DiVjLVVt.js","./index-D9m13C7l.js","./index-qX1GRw9I.css","./Conversation-BVNmvuHR.css","./TerminalPane-BrSy-0jI.css"])))=>i.map(i=>d[i]);
2
- import{D as e,E as t,S as n,_t as r,b as i,c as a,ct as o,d as s,f as c,ft as l,gt as u,it as d,l as f,nt as p,ot as m,rt as h,st as g,t as _,tt as v,ut as y,v as b,x}from"./Dropdown-BnYLBw2s.js";import{A as S,D as C,E as w,F as T,I as E,L as D,M as O,N as k,O as A,T as j,a as M,j as N,k as P,o as ee,s as te,t as ne,v as re,w as ie,x as ae}from"./index-D9m13C7l.js";import{a as oe,n as se,o as ce,r as le,t as ue}from"./Conversation-DiVjLVVt.js";import{t as de}from"./Markdown-zJQlHcvy.js";import{n as fe,t as pe}from"./MessageComposer-CBI6RiJq.js";import{r as me}from"./WorkspaceTree-BhDZe1go.js";var F=u(),I=n();function he({title:e,busy:t,onSave:n}){let[r,i]=(0,F.useState)(!1),[a,o]=(0,F.useState)(e);return r?(0,I.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,I.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,I.jsx)(`h2`,{children:(0,I.jsx)(`button`,{type:`button`,className:`session-rename`,title:`重命名会话`,"aria-label":`重命名会话:${e}`,onClick:()=>{o(e),i(!0)},children:e})})}var ge=o({id:y().uuid(),directory:y(),title:y(),cwd:y(),createdAt:y(),state:v([`running`,`exited`]),exitCode:g().nullable()}),L={id:y().uuid(),directory:y().min(1).max(200)},R={cols:g().int().min(2).max(500),rows:g().int().min(1).max(300)};d(`type`,[o({type:m(`create`),...L,...R,title:y().trim().min(1).max(160)}),o({type:m(`attach`),...L}),o({type:m(`detach`),...L}),o({type:m(`input`),...L,data:y().max(65536)}),o({type:m(`resize`),...L,...R}),o({type:m(`rename`),...L,title:y().trim().min(1).max(160)}),o({type:m(`close`),...L})]);var _e=d(`type`,[o({type:m(`size`),id:y(),...R}),o({type:m(`inventory`),directories:p(y()),terminals:p(ge)}),o({type:m(`snapshot`),id:y(),data:y(),cols:g(),rows:g(),seq:g()}),o({type:m(`output`),id:y(),data:y(),seq:g()}),o({type:m(`result`),id:y(),operation:y(),error:y().optional()})]);function ve(e,t){let n=(0,F.useRef)(null),i=(0,F.useRef)(new Set),[a,o]=(0,F.useState)(!1),[s,c]=(0,F.useState)([]),[l,u]=(0,F.useState)([]);(0,F.useEffect)(()=>{if(!t)return;let a=!1,s,l,d=()=>{let t=new URL(r(`/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=_e.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 i.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,F.useCallback)(e=>(i.current.add(e),()=>{i.current.delete(e)}),[]),f=(0,F.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,F.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])}}o({provider:C,cursor:y().optional(),session:S.optional()});var ye=o({id:S,title:y(),cwd:y(),updatedAt:y().datetime().nullable(),active:h().default(!1)}),be=o({sessions:p(ye),nextCursor:y().nullable()}),xe=o({command:N,history:be.nullable()});function Se(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 z({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,F.useState)(!1),[p,m]=(0,F.useState)(``),[h,g]=(0,F.useState)(),_=(0,F.useRef)(null),v=(0,F.useRef)(null),y=(0,F.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===p);(0,F.useEffect)(()=>m(``),[n]),(0,F.useEffect)(()=>{if(!u)return;let e=e=>{_.current?.contains(e.target)||d(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[u]),(0,F.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,F.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,I.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,I.jsxs)(`div`,{className:`combobox-field`,ref:v,children:[(0,I.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===p),n=t<0?e.key===`ArrowDown`?0:C.length-1:(t+(e.key===`ArrowDown`?1:-1)+C.length)%C.length;m(C[n]?.value??``)}else e.key===`Enter`&&u&&w>=0?(e.preventDefault(),T(S[w])):e.key===`Tab`&&d(!1)}}),(0,I.jsx)(f,{icon:u?`chevronUp`:`chevronDown`,label:`${u?`收起`:`展开`}${t}`,disabled:s,"aria-expanded":u,"aria-controls":`${e}-list`,onClick:()=>{d(!u),y.current?.focus()}})]}),u&&(0,I.jsxs)(`div`,{className:`combobox-popup`,style:h,children:[(0,I.jsxs)(`div`,{id:`${e}-list`,role:`listbox`,"aria-label":t,"aria-busy":o,children:[S.map((t,r)=>(0,I.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===p?`active`:``}`,title:`${t.label} · ${t.value}`,onMouseDown:e=>e.preventDefault(),onClick:()=>T(t),children:[(0,I.jsxs)(`span`,{className:`combobox-option-copy`,children:[(0,I.jsx)(`span`,{children:t.label}),t.description&&(0,I.jsx)(`small`,{children:t.description})]}),t.detail&&(0,I.jsx)(`span`,{className:`combobox-option-detail`,children:t.detail})]},t.value)),o&&(0,I.jsx)(`p`,{className:`combobox-message`,role:`status`,children:`正在读取…`}),!o&&!S.length&&(0,I.jsx)(`p`,{className:`combobox-message`,children:c})]}),l&&(0,I.jsx)(`div`,{className:`combobox-footer`,children:l})]})]})}function Ce({directory:n,provider:r,providers:i,sessions:a,request:o,onClose:l,onImport:u}){let[d,p]=(0,F.useState)(r),[m,h]=(0,F.useState)([]),[g,_]=(0,F.useState)(null),[v,y]=(0,F.useState)(``),[b,x]=(0,F.useState)(null),[C,w]=(0,F.useState)(``),T=(0,F.useRef)(null),E=e=>a.find(t=>t.provider===d&&(t.nativeSession??t.resumeSession)===e);async function D(t,r){let i=e();for(await o(`web/local-agents/${n}/history`,N,{method:`POST`,signal:r,body:{id:i,argument:JSON.stringify({provider:d,...t})}});!r.aborted;){let e=await o(`web/local-agents/${n}/history/${i}`,xe,{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 O(t,r,i){let a=E(t.id)??await o(`web/local-agents/${n}/sessions`,P,{method:`POST`,signal:i,body:{id:e(),title:t.title,provider:d,resumeSession:t.id,historyRequest:r}});i.aborted||u(a)}async function k(e,n){T.current?.abort();let r=new AbortController;T.current=r,x(e),w(``);try{await n(r.signal)}catch(e){r.signal.aborted||w(t(e))}finally{r.signal.aborted||x(null)}}let A=e=>k(`list`,async t=>{let n=await D(e?{cursor:e}:{},t);t.aborted||(h(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??``))}),_(n.nextCursor))});(0,F.useEffect)(()=>(h([]),_(null),y(``),A(),()=>T.current?.abort()),[d,n,o]);let j=m.find(e=>e.id===v),M=b===`import`;return(0,I.jsx)(s,{id:`computer-import-session`,title:`导入历史会话`,onClose:l,children:(0,I.jsxs)(`form`,{className:`native-history`,onSubmit:e=>{e.preventDefault(),k(`import`,async e=>{let t=v.trim(),n=E(t);if(n)return u(n);if(j)return O(j,j.requestId,e);let r=await D({session:t},e),i=r.sessions.find(e=>e.id===t);if(!i)throw Error(`找不到此目录中的会话。`);await O(i,r.id,e)})},children:[(0,I.jsx)(ee,{label:`历史会话 Agent`,value:d,onChange:p,providers:[r,...i],disabled:M}),(0,I.jsxs)(`div`,{className:`field`,children:[(0,I.jsx)(`label`,{htmlFor:`native-history-session`,children:`Session`}),(0,I.jsxs)(`div`,{className:`native-history-input-row`,children:[(0,I.jsx)(z,{id:`native-history-session`,label:`历史会话`,value:v,onChange:y,placeholder:`选择会话或输入 ID`,disabled:M,loading:b===`list`,empty:v?`未找到匹配会话,可直接输入 Session ID。`:`此目录暂无历史会话,可输入 Session ID。`,options:m.map(e=>({value:e.id,label:e.title,description:e.id,detail:E(e.id)?`已接入`:e.active?`工作中`:Se(e.updatedAt),disabled:e.active&&!E(e.id)})),footer:(0,I.jsxs)(I.Fragment,{children:[g&&(0,I.jsx)(`button`,{className:`native-history-more`,type:`button`,disabled:!!b,onClick:()=>void A(g),children:`加载更多`}),(0,I.jsx)(f,{icon:`refresh`,label:`刷新历史会话`,disabled:!!b,onClick:()=>void A()})]})},d),(0,I.jsx)(`button`,{type:`submit`,disabled:M||!S.safeParse(v.trim()).success||!!j?.active&&!E(j.id),children:M?`正在导入…`:E(v.trim())?`打开`:`导入`})]})]}),(0,I.jsx)(c,{error:!0,children:C}),(0,I.jsx)(`small`,{className:`muted`,children:`请先退出原终端会话。`})]})})}var B=o({cwd:y(),repository:y().nullable(),capturedAt:y(),truncated:h(),files:p(o({path:y(),section:v([`staged`,`working`,`untracked`]),patch:y().max(5e4),binary:h(),truncated:h()})).max(100)}),we=o({command:N,diff:B.nullable()});function Te({session:n,request:r,onClose:i}){let[a,o]=(0,F.useState)(e),[l,u]=(0,F.useState)(),[d,f]=(0,F.useState)(``);(0,F.useEffect)(()=>{let e=new AbortController,i;u(void 0),f(``);let o=async()=>{try{let t=await r(`web/local-agent-sessions/${n}/diff/${a}`,we,{signal:e.signal});if(e.signal.aborted)return;u(t),[`queued`,`running`].includes(t.command.state)&&(i=setTimeout(()=>void o(),1e3))}catch(n){e.signal.aborted||f(t(n))}};return r(`web/local-agent-sessions/${n}/commands`,N,{method:`POST`,signal:e.signal,body:{id:a,kind:`diff`}}).then(o).catch(n=>{e.signal.aborted||f(t(n))}),()=>{e.abort(),clearTimeout(i)}},[n,r,a]);let p=l?.diff,m=!d&&(!l||[`queued`,`running`].includes(l.command.state));return(0,I.jsx)(s,{id:`workspace-diff`,title:`工作目录改动`,onClose:i,children:(0,I.jsxs)(`div`,{className:`workspace-diff`,children:[(0,I.jsx)(`p`,{className:`muted`,children:`包含此目录内所有未提交改动,也可能包含其他会话或工具的修改。`}),(0,I.jsxs)(`div`,{className:`workspace-diff-toolbar`,children:[(0,I.jsx)(`span`,{className:`muted`,children:p?`读取于 ${new Date(p.capturedAt).toLocaleTimeString()}`:m?`正在从开发机读取…`:``}),(0,I.jsx)(`button`,{type:`button`,disabled:m,onClick:()=>o(e()),children:`刷新`})]}),(0,I.jsx)(c,{error:!0,children:d||l?.command.error}),p&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`code`,{className:`workspace-diff-path`,children:p.cwd}),p.repository?p.files.length?null:(0,I.jsx)(`p`,{children:`当前目录没有未提交改动。`}):(0,I.jsx)(`p`,{children:`此目录不在 Git 仓库中。`}),p.truncated&&(0,I.jsx)(c,{children:`部分内容较大或无法预览,已限制显示范围。完整内容请在开发机查看。`}),p.files.map((e,t)=>(0,I.jsxs)(`details`,{open:t===0,children:[(0,I.jsxs)(`summary`,{children:[(0,I.jsx)(`span`,{children:e.path}),(0,I.jsx)(`small`,{children:{staged:`已暂存`,working:`未暂存`,untracked:`未跟踪`}[e.section]})]}),e.binary?(0,I.jsx)(`p`,{className:`muted`,children:`二进制文件`}):e.patch?(0,I.jsx)(`pre`,{"aria-label":`${e.path} 差异`,children:(0,I.jsx)(`code`,{children:e.patch.split(`
3
- `).map((e,t)=>(0,I.jsxs)(`span`,{className:e.startsWith(`+`)?`diff-added`:e.startsWith(`-`)?`diff-removed`:e.startsWith(`@@`)?`diff-hunk`:``,children:[e,e?null:`\xA0`]},t))})}):(0,I.jsx)(`p`,{className:`muted`,children:`无可预览的文本差异。`}),e.truncated&&(0,I.jsx)(`small`,{className:`muted`,children:`此文件内容已截断或未展开。`})]},`${e.section}:${e.path}`))]})]})})}var Ee=(e,t,n)=>r(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/images/${encodeURIComponent(n)}`);function De({images:e,url:t,remove:n,disabled:r=!1}){return e.length?(0,I.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,I.jsxs)(`div`,{className:`session-image`,children:[(0,I.jsx)(`a`,{href:t(e.id),target:`_blank`,rel:`noreferrer`,title:e.name,children:(0,I.jsx)(`img`,{src:t(e.id),alt:e.name,loading:`lazy`})}),n&&(0,I.jsx)(`button`,{type:`button`,"aria-label":`移除图片 ${e.name}`,disabled:r,onClick:()=>n(e.id),children:(0,I.jsx)(a,{name:`close`,size:`small`})})]},e.id))}):null}function Oe(n,r,o){let s=x(),l=i(r,`computer-image-drafts`),[u,d]=(0,F.useState)(()=>s?.get(l)??{}),f=u[n]??[],p=e=>d(t=>({...t,[n]:typeof e==`function`?e(t[n]??[]):e}));(0,F.useEffect)(()=>{s?.set(l,u)},[s,l,u]);let[m,h]=(0,F.useState)(!1),[g,_]=(0,F.useState)(``),v=`${r}:${n}`,y=(0,F.useRef)(v),b=(0,F.useRef)(!1),S=(0,F.useRef)(null);y.current=v,(0,F.useEffect)(()=>{_(``)},[v]);async function C(r){if(!b.current&&n){if(r.length+f.length>4)_(`每条消息最多添加 4 张图片。`);else{b.current=!0,h(!0),_(``);try{for(let t of Array.from(r)){if(![`image/png`,`image/jpeg`,`image/webp`].includes(t.type)||t.size>5242880||!t.size)throw Error(`请选择不超过 5 MB 的 PNG、JPEG 或 WebP 图片。`);let r=await new Promise((e,n)=>{let r=new FileReader;r.onload=()=>e(String(r.result).split(`,`,2)[1]),r.onerror=()=>n(Error(`图片读取失败。`)),r.readAsDataURL(t)}),i=await o(`web/local-agent-sessions/${n}/images`,T,{method:`POST`,body:{id:e(),name:t.name.slice(0,200),data:r}});if(y.current!==v)return;p(e=>[...e,i])}}catch(e){y.current===v&&_(t(e))}finally{b.current=!1,h(!1)}}}}let w=e=>Ee(r,n,e);return{images:f,busy:m,add:C,clear:()=>{y.current===v&&p([])},picker:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`input`,{ref:S,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":`选择图片`,disabled:e||m,onChange:e=>{e.target.files&&C(e.target.files),e.target.value=``}}),(0,I.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`添加图片`,title:`添加图片,也可粘贴或拖入`,disabled:e||m,onClick:()=>S.current?.click(),children:(0,I.jsx)(a,{name:`attachment`,size:`small`})})]}),preview:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(De,{images:f,url:w,disabled:e||m,remove:e=>p(t=>t.filter(t=>t.id!==e))}),m&&(0,I.jsx)(`small`,{className:`muted`,children:`正在上传图片…`}),(0,I.jsx)(c,{error:!0,children:g})]})}}function ke({message:n,session:r,request:i,refresh:a}){let[o,s]=(0,F.useState)(!1),[l,u]=(0,F.useState)(n.body),[d,f]=(0,F.useState)(!1),[p,m]=(0,F.useState)(``),h=(0,F.useRef)(void 0),g=n.queue;if(!g)return null;let _={offered:`待本地接收`,received:`待本地接收`,queued:`排队中`,dispatching:`正在发送`,running:`执行中`,cancelled:`已撤回`,uncertain:`需要核对`};async function v(o){let c=JSON.stringify({inputId:n.id.replace(/^input:/,``),expectedRevision:g.revision,...o===`queue-edit`?{body:l}:{}}),u=`${o}:${c}`;h.current?.fingerprint!==u&&(h.current={fingerprint:u,id:e()}),f(!0),m(``);try{await i(`web/local-agent-sessions/${r}/commands`,N,{method:`POST`,body:{id:h.current.id,kind:o,argument:c}}),s(!1),h.current=void 0,a()}catch(e){m(t(e))}finally{f(!1)}}return(0,I.jsxs)(`div`,{className:`queued-message`,children:[_[g.state]&&(0,I.jsx)(`small`,{className:`muted`,children:_[g.state]}),o?(0,I.jsxs)(`div`,{className:`queued-message-editor`,children:[(0,I.jsx)(`textarea`,{"aria-label":`编辑待发送消息`,value:l,onChange:e=>u(e.target.value),disabled:d||!g.editable,autoFocus:!0}),(0,I.jsxs)(`div`,{className:`queued-message-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:d||!g.editable||!l.trim(),onClick:()=>void v(`queue-edit`),children:`保存修改`}),(0,I.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>s(!1),children:`取消编辑`})]})]}):g.editable&&(0,I.jsxs)(`div`,{className:`queued-message-actions`,children:[(0,I.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>{u(n.body),s(!0)},children:`编辑`}),(0,I.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>void v(`queue-cancel`),children:`撤回`})]}),(0,I.jsx)(c,{error:!0,children:p})]})}function Ae(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 je({children:e}){return(0,I.jsx)(`div`,{className:`computer-divider`,children:(0,I.jsx)(`span`,{children:e})})}function Me({message:e}){let t=e.state===`succeeded`?`已工作`:e.state===`interrupted`?`已停止`:e.state===`failed`?`执行失败`:`需要核对`;return(0,I.jsxs)(je,{children:[t,e.activity?.durationMs===void 0?``:` · ${Ae(e.activity.durationMs)}`]})}var Ne={offered:`待本地接收`,pending:`待投递`,human_routed:`未送达本地`,failed:`失败`,uncertain:`需要核对`};function Pe({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r}){let i=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),o=new Map,s=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),c=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&s.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&!o.has(t.activity.turnId)&&o.set(t.activity.turnId,t.id);return(0,I.jsx)(`div`,{className:`computer-messages`,children:e.map(e=>{let l=e.activity;if(l?.kind===`commentary`&&(s.has(JSON.stringify([l.turnId,l.itemId]))||c.has(JSON.stringify([l.turnId,e.body]))))return null;if(e.role===`system`)return(0,I.jsx)(je,{children:e.body},e.id);if(l?.kind===`turn`)return o.has(l.turnId)?null:(0,I.jsx)(Me,{message:e},e.id);if(e.role===`user`)return(0,I.jsxs)(ue,{mine:!0,author:`你`,time:e.createdAt,children:[n&&e.images?.length?(0,I.jsx)(De,{images:e.images,url:n}):null,(0,I.jsx)(`div`,{className:`markdown`,children:(0,I.jsx)(de,{children:e.body})}),e.queue&&r?r(e):Ne[e.state]&&(0,I.jsx)(ce,{label:Ne[e.state],state:e.state})]},e.id);if(l?.kind===`tool`)return(0,I.jsxs)(`details`,{className:`computer-tool`,children:[(0,I.jsxs)(`summary`,{title:l.label,children:[(0,I.jsx)(a,{name:`chevron`,size:`small`}),(0,I.jsx)(`span`,{className:`computer-tool-label`,children:l.label??`工具调用`}),(0,I.jsxs)(`span`,{className:`computer-tool-status`,children:[e.state===`running`?`进行中`:e.state===`failed`?`失败`:e.state===`interrupted`?`已停止`:e.state===`uncertain`?`需核对`:``,l.durationMs!==void 0&&(0,I.jsx)(`span`,{children:Ae(l.durationMs)})]})]}),(0,I.jsx)(`pre`,{children:e.body})]},e.id);let u=l?.kind===`answer`&&o.get(l.turnId)===e.id?i.get(l.turnId):void 0;return(0,I.jsxs)(F.Fragment,{children:[u&&(0,I.jsx)(Me,{message:u}),(0,I.jsx)(`article`,{className:`computer-agent-message ${l?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,I.jsx)(`div`,{className:`markdown`,children:(0,I.jsx)(de,{children:e.body})})})]},e.id)})})}var Fe={codex:{name:`Codex`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/openai.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eOpenAI%3c/title%3e%3cpath%20d='M9.205%208.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357%201.356-.523%202.117-.523%202.854%200%204.662%202.212%204.662%204.566%200%20.167%200%20.357-.024.547l-4.71-2.759a.797.797%200%2000-.856%200l-5.97%203.473zm10.609%208.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473%201.95-1.118a.433.433%200%2001.476%200l4.543%202.617c1.309.76%202.189%202.378%202.189%203.948%200%201.808-1.07%203.473-2.76%204.163zM7.802%2012.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545%201.95-4.472%204.591-4.472%201%200%201.927.333%202.712.928L8.23%205.067c-.285.166-.428.404-.428.737v6.898zM12%2015.128l-2.795-1.57v-3.33L12%208.658l2.795%201.57v3.33L12%2015.128zm1.796%207.23c-1%200-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974%201.142c.167.095.238.238.238.428v5.233c0%202.545-1.974%204.472-4.614%204.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482%204.482%200%20014.21%206.327v5.423c0%20.333.143.571.428.738l5.947%203.449-1.95%201.118a.432.432%200%2001-.476%200zm-.262%203.9c-2.688%200-4.662-2.021-4.662-4.519%200-.19.024-.38.047-.57l4.686%202.71c.286.167.571.167.856%200l5.97-3.448v2.26c0%20.19-.07.333-.237.428l-4.543%202.616c-.619.357-1.356.523-2.117.523zm5.899%202.83a5.947%205.947%200%20005.827-4.756C22.287%2018.339%2024%2015.84%2024%2013.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498%200-3.401-2.759-5.947-5.946-5.947-.642%200-1.26.095-1.88.31A5.962%205.962%200%200010.205%200a5.947%205.947%200%2000-5.827%204.757C1.713%205.447%200%207.945%200%2010.49c0%201.666.713%203.283%201.998%204.448-.119.5-.19%201-.19%201.499%200%203.401%202.759%205.946%205.946%205.946.642%200%201.26-.095%201.88-.309a5.96%205.96%200%20004.162%201.713z'%3e%3c/path%3e%3c/svg%3e`},claude:{name:`Claude Code`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/claude.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eClaude%3c/title%3e%3cpath%20d='M4.709%2015.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0%2011.784l.055-.352.48-.321.686.06%201.52.103%202.278.158%201.652.097%202.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686%201.908%201.476%202.491%201.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97%202.97%200%2001-.104-.729L6.283.134%206.696%200l.996.134.42.364.62%201.414%201.002%202.229%201.555%203.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286%201.851-.559%202.903-.364%201.942h.212l.243-.242.985-1.306%201.652-2.064.73-.82.85-.904.547-.431h1.033l.76%201.129-.34%201.166-1.064%201.347-.881%201.142-1.264%201.7-.79%201.36.073.11.188-.02%202.856-.606%201.543-.28%201.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061%201.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093%201.068%202.006%201.81%202.509%202.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649%202.345%203.521.122%201.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674%207.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434%201.967-2.18%202.945-1.726%201.845-.414.164-.717-.37.067-.662.401-.589%202.388-3.036%201.44-1.882.93-1.086-.006-.158h-.055L4.132%2018.56l-1.13.146-.487-.456.061-.746.231-.243%201.908-1.312-.006.006z'%3e%3c/path%3e%3c/svg%3e`},cursor:{name:`Cursor`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/claude.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eCursor%3c/title%3e%3cpath%20d='M22.106%205.68L12.5.135a.998.998%200%2000-.998%200L1.893%205.68a.84.84%200%2000-.419.726v11.186c0%20.3.16.577.42.727l9.607%205.547a.999.999%200%2000.998%200l9.608-5.547a.84.84%200%2000.42-.727V6.407a.84.84%200%2000-.42-.726zm-.603%201.176L12.228%2022.92c-.063.108-.228.064-.228-.061V12.34a.59.59%200%2000-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264%200%20.428.286.296.514z'%3e%3c/path%3e%3c/svg%3e`},pi:{name:`Pi`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M3%205h18v3h-3v9c0%201%20.5%201.5%201.5%201.5H21V21h-2c-3%200-4-1.5-4-4V8H9v6c0%204-1.5%206.5-5%207l-1-2.5C5.5%2018%206%2016.5%206%2014V8H3z'/%3e%3c/svg%3e`},opencode:{name:`OpenCode`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='96%2064%20288%20384'%20fill='%23393936'%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20opacity='.4'/%3e%3cpath%20fill-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'/%3e%3c/svg%3e`}};function Ie({provider:e}){let{name:t,logo:n}=Fe[e];return(0,I.jsx)(`img`,{className:`agent-logo`,src:n,alt:t,title:t,"data-provider":e,width:24,height:24})}function Le({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){let[i,o]=(0,F.useState)(n),[s,c]=(0,F.useState)(!!n),l=`其他回答`,u=(0,F.useRef)(null),d=(0,F.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(`
4
- `).map(e=>t.measureText(e).width));u.current.style.setProperty(`--reply-width`,`${Math.ceil(n+(s?52:26))}px`)},[i,s,l]),f=fe(i,d);return(0,I.jsxs)(`form`,{ref:u,className:`inline-reply${s?` 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&&o(``)})},children:[(0,I.jsx)(`textarea`,{ref:f,rows:1,"aria-label":`自定义回答`,placeholder:r??`${l}…`,value:i,disabled:e,onChange:e=>o(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),!e&&i.trim()&&t.currentTarget.form?.requestSubmit())}}),s&&(0,I.jsx)(`button`,{className:`inline-reply-send`,type:`submit`,disabled:e||!i.trim(),"aria-label":`发送${l}`,title:`发送${l}`,children:(0,I.jsx)(a,{name:`send`,size:`small`})})]})}function Re({question:n,session:r,request:i,refresh:s}){let[u,d]=(0,F.useState)({}),[f,p]=(0,F.useState)({}),[m,g]=(0,F.useState)(``),[_,v]=(0,F.useState)(!1),[y,b]=(0,F.useState)(!1),[x,S]=(0,F.useState)(``),C=(0,F.useRef)(null),w=(0,F.useRef)(!1),T=(0,F.useRef)(void 0);(0,F.useEffect)(()=>{if(n.state!==`pending`||w.current||!C.current)return;let e=!1,a=()=>{if(!e||document.visibilityState!==`visible`||!C.current)return;let a=C.current.getBoundingClientRect();a.bottom>0&&a.top<innerHeight&&i(`web/local-agent-sessions/${r}/questions/${n.id}/presented`,o({ok:h()}),{method:`POST`}).then(()=>{w.current=!0}).catch(e=>g(t(e)))},s=new IntersectionObserver(t=>{e=t.some(e=>e.isIntersecting),a()});return s.observe(C.current),document.addEventListener(`visibilitychange`,a),()=>{s.disconnect(),document.removeEventListener(`visibilitychange`,a)}},[n.id,n.state,r,i]);async function E(a){let o=JSON.stringify(a);T.current?.fingerprint!==o&&(T.current={fingerprint:o,value:{...a,id:e()}}),v(!0),g(``);try{return await i(`web/local-agent-sessions/${r}/questions/${n.id}/answers`,l(),{method:`POST`,body:T.current.value}),T.current=void 0,s(),!0}catch(e){return g(t(e)),!1}finally{v(!1)}}let D=n.response,O=n.state===`answered`,k=[`expired`,`cancelled`].includes(n.state),A=[`human_routed`,`failed`,`handled`].includes(n.submissionState??``)&&!O,j=n.state===`pending`&&(!D||A),M=n.kind===`plan`,N=n.actions?.find(e=>e.id===D?.actionId),P=k?`已过期`:n.state===`uncertain`||n.submissionState===`uncertain`?`需核对`:O?M?N?.label??`已处理`:n.approval?D?.decision===!0?`已允许`:D?.decision===!1?`已拒绝`:`已处理`:N?N.label:D?``:`已回答`:A?`请重新提交`:D?`正在提交`:``,ee=k||D?.decision===!1||A?`close`:O?`check`:`clock`,te=n.questions.length>1||n.questions.some(e=>e.multiSelect),ne=(e=u)=>E({body:n.questions.length===1?e[n.questions[0].id]||(f[n.questions[0].id]??[]).join(`、`):JSON.stringify(e),...n.kind||n.questions.some(e=>e.multiSelect)?{answers:e}:{},...n.questions.some(e=>e.multiSelect)?{selections:f}:{}});return(0,I.jsxs)(`div`,{className:`native-question ${M?`native-plan`:``}`,ref:C,children:[M?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`native-plan-heading`,children:[(0,I.jsx)(a,{name:`file`,size:`small`}),(0,I.jsx)(`span`,{children:`实施计划`})]}),j?(0,I.jsx)(`div`,{className:`native-plan-content markdown`,children:(0,I.jsx)(de,{children:n.plan??``})}):(0,I.jsxs)(`details`,{className:`native-plan-history markdown`,children:[(0,I.jsx)(`summary`,{children:`查看计划`}),(0,I.jsx)(de,{children:n.plan??``})]}),j&&(0,I.jsxs)(I.Fragment,{children:[!y&&(0,I.jsx)(`div`,{className:`question-actions native-plan-actions ${n.actions&&n.actions.length>3?`native-plan-actions-expanded`:``}`,children:n.actions?.map(e=>(0,I.jsx)(`button`,{type:`button`,disabled:_,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&&n.actions?.find(e=>e.id===`implement`)?.description&&(0,I.jsxs)(`small`,{className:`native-plan-note muted`,children:[`开始实施:`,n.actions.find(e=>e.id===`implement`).description]}),y&&(0,I.jsxs)(`form`,{className:`native-plan-feedback`,onSubmit:e=>{e.preventDefault(),E({body:x,actionId:`revise`})},children:[(0,I.jsxs)(`label`,{children:[`修改意见`,(0,I.jsx)(`textarea`,{autoFocus:!0,value:x,onChange:e=>S(e.target.value),placeholder:`说明希望调整的部分,Agent 将修改后再次请求确认`})]}),(0,I.jsxs)(`div`,{className:`question-actions native-plan-feedback-actions`,children:[(0,I.jsx)(`button`,{className:`primary`,disabled:_||!x.trim(),children:`提交修改意见`}),(0,I.jsx)(`button`,{type:`button`,disabled:_,onClick:()=>b(!1),children:`返回计划`})]})]})]}),!j&&D?.actionId===`revise`&&D.answers.feedback&&(0,I.jsx)(`div`,{className:`question-response`,children:D.answers.feedback})]}):(0,I.jsxs)(I.Fragment,{children:[n.questions.map(e=>(0,I.jsxs)(`div`,{className:`native-question-part`,children:[(0,I.jsx)(`p`,{className:n.approval?`native-approval-detail`:``,children:e.text}),j&&(0,I.jsx)(`div`,{className:`question-options ${n.approval?`native-approval-options`:Object.values(e.descriptions??{}).some(Boolean)?`question-options-described`:``}`,children:(n.approval?[`允许`,`拒绝`]:e.options).map(t=>(0,I.jsxs)(`button`,{type:`button`,disabled:_,"aria-pressed":e.multiSelect?f[e.id]?.includes(t)??!1:u[e.id]===t,onClick:()=>{if(e.multiSelect){p(n=>({...n,[e.id]:n[e.id]?.includes(t)?n[e.id].filter(e=>e!==t):[...n[e.id]??[],t]}));return}let r={...u,[e.id]:t};d(r),n.approval?E({body:t,decision:t===`允许`}):te||ne(r)},children:[(0,I.jsxs)(`span`,{className:`question-option-label`,children:[e.multiSelect&&(0,I.jsx)(`span`,{"aria-hidden":`true`,className:`question-check`,children:f[e.id]?.includes(t)&&(0,I.jsx)(a,{name:`check`,size:`small`})}),t]}),e.descriptions?.[t]&&(0,I.jsx)(`small`,{children:e.descriptions[t]})]},t))}),!n.approval&&e.freeText&&j&&(0,I.jsx)(Le,{initialValue:e.initialValue,placeholder:e.placeholder,disabled:_,onSend:async t=>{let n={...u,[e.id]:t};return d(n),te?!0:ne(n)}}),j&&te&&u[e.id]&&!e.options.includes(u[e.id])&&(0,I.jsx)(`small`,{children:u[e.id]}),!j&&!n.approval&&(D?.answers[e.id]||D?.selections?.[e.id]?.length)&&(0,I.jsxs)(`div`,{className:`question-response`,children:[(0,I.jsx)(a,{name:O?`check`:`clock`,size:`small`}),(0,I.jsx)(`span`,{children:[...D.selections?.[e.id]??[],D.answers[e.id]].filter(Boolean).join(`、`)})]})]},e.id)),j&&!n.approval&&n.actions?.length&&(0,I.jsx)(`div`,{className:`question-actions`,children:n.actions.map(e=>(0,I.jsx)(`button`,{disabled:_,onClick:()=>void E({body:e.label,actionId:e.id}),children:e.label},e.id))}),j&&!n.approval&&te&&(0,I.jsx)(`div`,{className:`question-actions`,children:(0,I.jsx)(`button`,{disabled:_||n.questions.some(e=>!u[e.id]?.trim()&&!f[e.id]?.length),onClick:()=>void ne(),children:`回答`})}),j&&n.approval&&n.autoApprove!==!1&&(0,I.jsx)(`small`,{className:`muted`,children:`60 秒后自动允许`})]}),P&&(0,I.jsxs)(`small`,{className:`question-result`,children:[(0,I.jsx)(a,{name:ee,size:`small`}),P]}),(0,I.jsx)(c,{error:!0,children:m})]})}var ze={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`,ultra:`极致`,none:`无`,off:`关闭`};function V({id:e,label:t,current:n,options:r,disabled:i,onSelect:o}){let s=r.find(e=>e.value===n);return(0,I.jsx)(_,{id:`${e}-menu`,triggerId:e,placement:`top`,className:`composer-menu composer-choice`,label:`选择${t}`,disabled:i,routeKey:n,trigger:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`span`,{title:`${t}:${s?.label??n}`,children:s?.shortLabel??s?.label??n}),(0,I.jsx)(a,{name:`chevronDown`,size:`small`})]}),children:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`div`,{className:`composer-menu-heading`,children:t}),r.map(t=>(0,I.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),o(t.value)},children:[(0,I.jsxs)(`span`,{className:`composer-option-copy`,children:[(0,I.jsx)(`span`,{children:t.label}),t.description&&(0,I.jsx)(`small`,{children:t.description})]}),t.value===n&&(0,I.jsx)(a,{name:`check`,size:`small`})]},t.value))]})})}function Be({session:e,models:t,busy:n,available:r,online:i,commands:o,controls:s,draft:c,onInsert:l,onConfig:u}){let[d,f]=(0,F.useState)(!1);(0,F.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`,v=e.provider===`cursor`,y=e.provider===`pi`,b=s??O(e.provider),x=m?.effortLabel??`思考强度`,S=e=>m?.effortLabel?e:ze[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 k=m?.id===e.effectiveConfig?.model?e.effectiveConfig?.effort:m?.defaultEffort,A=[{value:``,label:k?`默认 · ${S(k)}`:`默认${x}`,shortLabel:k?S(k):m?.effortLabel??`强度`},...(m?.efforts??[]).map(e=>({value:e,label:S(e)}))];return e.config.effort&&!A.some(t=>t.value===e.config.effort)&&A.push({value:e.config.effort,label:S(e.config.effort)}),(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(_,{id:`session-commands`,triggerId:`session-command-trigger`,label:`命令与 Skills`,placement:`top`,className:`composer-menu composer-commands`,routeKey:e.id,trigger:(0,I.jsx)(a,{name:`command`,size:`small`}),open:d,onOpenChange:f,focusFirst:!1,disabled:h||!i,children:e=>(0,I.jsxs)(I.Fragment,{children:[[...o].sort((e,t)=>e.name.localeCompare(t.name,`en`)).map(t=>(0,I.jsx)(`button`,{type:`button`,role:`menuitem`,title:[t.description,t.path].filter(Boolean).join(`
5
- `),onClick:()=>{e(),l(t)},children:(0,I.jsxs)(`span`,{className:`composer-command-row`,children:[(0,I.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,I.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!o.length&&(0,I.jsx)(`div`,{className:`composer-menu-heading`,children:`尚未获取命令`})]})}),(0,I.jsx)(V,{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,...v?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(!v&&!y&&e.provider!==`opencode`||(m?.efforts.length??0)>0||!!e.config.effort)&&(0,I.jsx)(V,{id:`session-effort`,label:x,current:e.config.effort??``,options:A,disabled:h,onSelect:t=>u({...e.config,effort:t||null})}),m?.options?.map(t=>(0,I.jsx)(V,{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)),b.map(t=>(0,I.jsx)(V,{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 Ve=(0,F.lazy)(()=>ne(()=>import(`./TerminalPane-GU69G9Ak.js`),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url)),He=o({ok:h()}),Ue={idle:`空闲`,working:`工作中`,waiting:`等待回答`,queued:`等待执行`,uncertain:`需要核对`,human:`人工处理`,offered:`待本地接收`,accepted:`本地已接手`,human_routed:`未送达本地`,pending:`待投递`,sent:`已发送`,succeeded:`已完成`,running:`进行中`,failed:`失败`};function H({navigate:e,memberId:t}){let{request:n,projectId:r}=j(),i=(0,F.useCallback)(e=>n(`web/local-agent-settings`,w,{signal:e}),[n]),a=b(i,3e4);return(0,F.useEffect)(()=>{let e=()=>void a.reload();return window.addEventListener(`teammy:local-access`,e),()=>window.removeEventListener(`teammy:local-access`,e)},[a.reload]),a.error?(0,I.jsx)(c,{error:!0,children:a.error}):a.data?(0,I.jsx)(We,{localAvailable:a.data.accessible,navigate:e,memberId:t},`${r}/${t}`):null}function We({localAvailable:n,navigate:o,memberId:u}){let d=j(),p=x(),m=i(d.projectId,u,`computer-selection`),h=i(d.projectId,u,`computer-drafts`),g=p?.get(m),[v,y]=(0,F.useState)(()=>new Set),[S,w]=(0,F.useState)(()=>({project:d.projectId,directory:new URLSearchParams(location.search).get(`directory`)??g?.directory??``,session:new URLSearchParams(location.search).get(`session`)??(new URLSearchParams(location.search).has(`terminal`)?``:g?.session??``),terminal:new URLSearchParams(location.search).get(`terminal`)??(new URLSearchParams(location.search).has(`session`)?``:g?.terminal??``)})),[T,O]=(0,F.useState)(``),[N,ee]=(0,F.useState)(!1),[ne,ue]=(0,F.useState)(!1),[de,fe]=(0,F.useState)(!1),[ge,L]=(0,F.useState)(()=>p?.get(h)??{}),R=ge[S.session]??``,_e=e=>L(t=>({...t,[S.session]:typeof e==`function`?e(t[S.session]??``):e}));(0,F.useEffect)(()=>{p?.set(h,ge)},[p,h,ge]);let[ye,be]=(0,F.useState)(``),[xe,z]=(0,F.useState)(!1),[B,we]=(0,F.useState)(`codex`),[De,Ae]=(0,F.useState)(!1),[je,Me]=(0,F.useState)(``),[Ne,Fe]=(0,F.useState)(Date.now);(0,F.useEffect)(()=>{let e=setInterval(()=>Fe(Date.now()),6e4);return()=>clearInterval(e)},[]);let Le=(0,F.useRef)(null),ze=(0,F.useRef)(!0),V=(0,F.useRef)(void 0),H=(0,F.useRef)(e()),We=(0,F.useCallback)(async e=>n?[{...await d.request(`web/local-agent-computer`,te,{signal:e}),project:d.projectId}]:[],[d,n]),U=b(We,3e3),W=U.data?.find(e=>e.project===S.project),G=ve(d.projectId,n),Ge=G.terminals.find(e=>e.id===S.terminal),Ke=(0,F.useRef)(Ge);Ge&&(Ke.current=Ge);let qe=Ge??(Ke.current?.id===S.terminal?Ke.current:void 0),K=W?.directories.find(e=>e.id===S.directory),q=W?.directories.find(e=>e.id===je)??K;ie(S.project);let J=(0,F.useCallback)((e,t,n)=>ie(S.project).request(e,t,n),[S.project]),Y=Oe(S.session,S.project,J),Je=(0,F.useCallback)(e=>S.session&&n?J(`web/local-agent-sessions/${S.session}`,A,{signal:e}):Promise.resolve(null),[J,S.session,n]),X=b(Je,15e3),[Ye,Xe]=(0,F.useState)(),Z=Ye?.session.id===S.session&&(!X.data||Ye.cursor>=X.data.cursor)?Ye:X.data;(0,F.useEffect)(()=>{if(!S.session||!n)return;let e=new EventSource(r(`/api/v1/projects/${encodeURIComponent(S.project)}/web/local-agent-sessions/${encodeURIComponent(S.session)}/events`)),i=!0;return e.addEventListener(`snapshot`,e=>{try{let t=A.parse(JSON.parse(e.data));i&&Xe(e=>e?.session.id===t.session.id&&e.cursor>t.cursor?e:t)}catch(e){O(t(e))}}),()=>{i=!1,e.close()}},[S.project,S.session,n]),(0,F.useEffect)(()=>{ze.current=!0},[S.project,S.session]),(0,F.useEffect)(()=>{ze.current&&Le.current&&(Le.current.scrollTop=Le.current.scrollHeight)},[Z?.cursor,Z?.messages.length]);let Q=Z?.session.id===S.session?Z.session:void 0,Ze=W?.capabilities.includes(`local-sessions-v1`),$=(e,t,n=``,r=``)=>{w({project:e,directory:t,session:n,terminal:r}),p?.set(m,{directory:t,session:n,terminal:r}),z(!1),Ae(!1),O(``);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===d.projectId&&history.replaceState(null,``,i)};(0,F.useEffect)(()=>{if(!S.directory&&U.data?.[0]?.directories[0]){let e=U.data[0],t=e.directories[0],n=e.sessions.find(e=>e.id===S.session);$(e.project,n?.directory??t.id,n?.id??t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id)}},[U.data]),(0,F.useEffect)(()=>{if(!Q)return;let e=()=>{document.visibilityState===`visible`&&J(`web/local-agent-sessions/${Q.id}/read`,He,{method:`POST`}).catch(e=>O(t(e)))};return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Q?.id,Z?.messages.at(-1)?.seq,J]);async function Qe(e){ee(!0),O(``);try{await e(),await Promise.all([X.reload(),U.reload()])}catch(e){O(t(e))}finally{ee(!1)}}function $e(e,t){return Qe(()=>d.request(`web/local-agent-sessions/${e.id}/metadata`,P,{method:`PUT`,body:{expectedRevision:e.metadataRevision,...t}}))}function et(e){let t=new URLSearchParams({tab:`directories`,directory:e,session:S.session});o(`/projects/${d.projectId}/settings?${t}`)}function tt(t=S.directory){let n=U.data?.[0],r=n?.directories.find(e=>e.id===t)??n?.directories[0];!r||!n?ue(!0):(H.current=e(),Me(r.id),z(!0),we(r.provider),O(``))}let[nt,rt]=(0,F.useState)(null);(0,F.useEffect)(()=>rt(null),[Q?.id]);let it=W?.catalogs.find(e=>e.provider===(Q?.provider??`codex`)&&(Q?.cwd?e.cwd===Q.cwd:e.directory===(Q?.executionDirectory??Q?.directory))),at=it?.commands??[],ot=it?.models??W?.providers.find(e=>e.id===Q?.provider)?.models??(Q?.provider===`codex`?W?.models??[]:[]),st=!!(ot.find(e=>e.id===(Q?.config.model??Q?.effectiveConfig?.model))??(Q?.config.model?void 0:ot.find(e=>e.isDefault)))?.images&&!!W?.capabilities.includes(`local-agent-images-v1`);return(0,I.jsxs)(le,{className:`computers-layout`,testId:`computers-page`,label:`本地会话`,tree:!0,navigation:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(re,{title:`电脑`,icon:`computers`}),(0,I.jsx)(`nav`,{className:`computer-navigation`,"aria-label":`电脑操作`,style:{"--tree-level":1},children:(0,I.jsxs)(ae,{className:`tree-item tree-folder`,leading:(0,I.jsx)(`span`,{className:`tree-chevron`}),"data-testid":`computer-create`,disabled:!n,onClick:()=>tt(),children:[(0,I.jsx)(a,{name:`plus`}),(0,I.jsx)(`span`,{className:`tree-name`,children:`新建会话`})]})}),(0,I.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":`目录与会话`,onKeyDown:me,children:(U.data??[]).map(e=>(0,I.jsx)(`div`,{role:`none`,children:e.directories.map(t=>{let n=`${e.project}/${t.id}`,r=!v.has(n);return(0,I.jsxs)(`div`,{role:`none`,children:[(0,I.jsxs)(`div`,{className:`computer-tree-row`,role:`none`,children:[(0,I.jsxs)(ae,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":r,style:{"--tree-level":1},leading:(0,I.jsx)(`span`,{className:`tree-chevron ${r?`expanded`:``}`,children:(0,I.jsx)(a,{name:`chevron`,size:`small`})}),onClick:()=>{S.directory!==t.id&&$(e.project,t.id,t.defaultSession??e.sessions.find(e=>e.directory===t.id)?.id),y(e=>{let t=new Set(e);return r?t.add(n):t.delete(n),t})},children:[(0,I.jsx)(a,{name:`files`}),(0,I.jsx)(`span`,{className:`tree-name`,title:t.name,children:t.name})]}),(0,I.jsx)(f,{icon:`plus`,label:`新建会话:${t.name}`,className:`computer-tree-action`,onClick:()=>tt(t.id)})]}),r&&(0,I.jsxs)(`div`,{role:`group`,children:[G.terminals.filter(e=>e.directory===t.id).map(n=>(0,I.jsx)(`div`,{className:`computer-tree-row computer-session-row computer-terminal-row`,role:`none`,children:(0,I.jsxs)(ae,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":S.terminal===n.id,style:{"--tree-level":2},leading:(0,I.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>$(e.project,t.id,``,n.id),children:[(0,I.jsx)(a,{name:`command`}),(0,I.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,I.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,I.jsx)(`time`,{dateTime:n.createdAt,children:n.state===`exited`?`已退出`:Se(n.createdAt,Ne)})]})]})},n.id)),e.sessions.filter(e=>e.directory===t.id).map(n=>(0,I.jsxs)(`div`,{className:`computer-tree-row computer-session-row`,role:`none`,children:[(0,I.jsxs)(ae,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":S.session===n.id&&S.project===e.project,style:{"--tree-level":2},leading:(0,I.jsx)(`span`,{className:`tree-chevron`,children:(0,I.jsx)(`span`,{className:`assistant-message-dot ${n.unread?`unread`:``}`})}),title:`${n.title} · ${k[n.provider]}`,onClick:()=>$(e.project,t.id,n.id),children:[(0,I.jsx)(Ie,{provider:n.provider}),(0,I.jsxs)(`span`,{className:`computer-session-copy`,children:[(0,I.jsx)(`span`,{className:`tree-name`,children:n.title}),(0,I.jsx)(`time`,{dateTime:n.updatedAt,title:new Date(n.updatedAt).toLocaleString(),children:Se(n.updatedAt,Ne)})]})]}),(0,I.jsx)(f,{icon:`pin`,className:`computer-tree-action computer-session-pin${n.pinned?` pinned`:``}`,label:`${n.pinned?`取消置顶`:`置顶`}:${n.title}`,"aria-pressed":n.pinned,title:n.pinned?`取消置顶,不再分配新工作`:`置顶,允许 Tim 分配工作`,disabled:N||n.archived,onClick:()=>void $e(n,{pinned:!n.pinned})}),n.archived?(0,I.jsx)(`span`,{title:`已归档`,role:`img`,"aria-label":`已归档`,children:(0,I.jsx)(a,{name:`archive`,size:`small`})}):n.state!==`idle`&&(0,I.jsx)(ce,{state:n.state,label:Ue[n.state]??n.state})]},n.id))]})]},t.id)})},e.project))}),(0,I.jsx)(c,{error:!0,children:U.error})]}),children:[ne&&(0,I.jsx)(M,{onClose:()=>ue(!1)}),De&&W&&q&&(0,I.jsx)(Ce,{directory:q.id,provider:q.provider,providers:W.providers.map(e=>e.id),sessions:W.sessions,request:J,onClose:()=>Ae(!1),onImport:e=>{$(S.project,e.directory,e.id),U.reload()}}),xe&&q&&(0,I.jsx)(s,{id:`computer-new-session`,title:`新建会话`,onClose:()=>z(!1),children:(0,I.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:t=>{t.preventDefault(),Qe(async()=>{if(B===`terminal`){let t=H.current;await G.request({type:`create`,id:t,directory:q.id,title:ye.trim(),cols:100,rows:28}),H.current=e(),be(``),$(S.project,q.id,``,t);return}let t=await J(`web/local-agents/${q.id}/sessions`,P,{method:`POST`,body:{id:H.current,title:ye,provider:B}});H.current=e(),z(!1),be(``),$(S.project,q.id,t.id)})},children:[W&&W.directories.length>1?(0,I.jsx)(E,{title:`执行目录`,children:(0,I.jsx)(`select`,{"aria-label":`执行目录`,disabled:N,value:q.id,onChange:e=>{Me(e.target.value),we(W.directories.find(t=>t.id===e.target.value)?.provider??`codex`)},children:W.directories.map(e=>(0,I.jsx)(`option`,{value:e.id,children:e.name},e.id))})}):(0,I.jsxs)(`p`,{className:`muted computer-create-scope`,children:[`目录:`,q.name]}),(0,I.jsxs)(`label`,{children:[`会话名称`,(0,I.jsx)(`input`,{autoFocus:!0,required:!0,disabled:N,placeholder:`会话名称`,value:ye,onChange:e=>be(e.target.value)})]}),(0,I.jsxs)(D,{label:`会话类型`,value:B,onChange:e=>we(e.target.value),disabled:N,children:[C.options.filter(e=>e===`codex`||(e===`claude`?W?.capabilities.includes(`local-agent-providers-v1`):W?.providers.some(t=>t.id===e))).map(e=>(0,I.jsx)(`option`,{value:e,children:k[e]},e)),G.directories.includes(q.id)&&(0,I.jsx)(`option`,{value:`terminal`,children:`终端`})]}),B===`terminal`&&(0,I.jsx)(`p`,{className:`muted computer-create-scope`,children:`在此目录启动本机 Shell,使用本机用户权限。`}),W?.providers.find(e=>e.id===B)?.error&&(0,I.jsx)(c,{children:W.providers.find(e=>e.id===B).error}),(0,I.jsx)(c,{error:!0,children:T}),(0,I.jsxs)(`div`,{className:`computer-create-options`,children:[B!==`terminal`&&(0,I.jsx)(`button`,{type:`button`,disabled:!W?.online||!W.capabilities.includes(`local-agent-history-v1`),onClick:()=>{z(!1),Ae(!0)},children:`导入历史会话`}),(0,I.jsx)(`button`,{type:`button`,onClick:()=>{z(!1),ue(!0)},children:`接入目录`}),(0,I.jsx)(`button`,{className:`primary`,disabled:N||!ye.trim()||(B===`terminal`?!G.directories.includes(q.id):!Ze),children:`创建`})]})]})}),S.terminal?qe?(0,I.jsx)(F.Suspense,{fallback:(0,I.jsx)(`div`,{className:`assistant-empty`,children:`正在打开终端…`}),children:(0,I.jsx)(Ve,{terminal:qe,connection:G,onClosed:()=>$(S.project,S.directory)},qe.id)}):(0,I.jsx)(`div`,{className:`assistant-empty`,children:G.connected?`终端已结束或电脑已重启,请新建终端。`:`正在连接终端…`}):K?(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(se,{title:Q?(0,I.jsx)(he,{title:Q.title,busy:N,onSave:e=>$e(Q,{title:e})},Q.id):(0,I.jsx)(`h2`,{children:K.name}),actions:(0,I.jsxs)(I.Fragment,{children:[W?.capabilities.includes(`local-agent-diff-v1`)&&(0,I.jsx)(f,{icon:`files`,label:`查看工作目录改动`,disabled:!Q||!W.online,onClick:()=>fe(!0)}),(0,I.jsx)(_,{id:`computer-session-menu`,triggerId:`computer-session-actions`,label:`会话操作`,trigger:(0,I.jsx)(a,{name:`more`}),className:`computer-create-menu`,routeKey:Q?.id??``,disabled:!Q,children:e=>(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`button`,{role:`menuitem`,disabled:N||Q?.archived,onClick:()=>{e(),Q&&$e(Q,{default:K.defaultSession!==Q.id})},children:K.defaultSession===Q?.id?`取消默认会话`:`设为默认会话`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),et(K.id)},children:`连接专用群`}),(0,I.jsx)(`button`,{role:`menuitem`,onClick:()=>{e(),et(K.id)},children:`执行位置`})]})})]})}),de&&Q&&(0,I.jsx)(Te,{session:Q.id,request:J,onClose:()=>fe(!1)},Q.id),!Ze&&(0,I.jsx)(c,{children:`升级客户端后可使用多个会话和网页对话。`}),(0,I.jsxs)(oe,{ref:Le,onScroll:e=>{let t=e.currentTarget;ze.current=t.scrollHeight-t.scrollTop-t.clientHeight<96},"aria-label":`本地会话记录`,children:[(0,I.jsx)(Pe,{messages:Z?.messages??[],imageUrl:e=>Ee(S.project,Q.id,e),renderQueue:e=>(0,I.jsx)(ke,{message:e,session:Q.id,request:J,refresh:X.reload}),renderQuestion:e=>(0,I.jsx)(Re,{question:e,session:Q.id,request:J,refresh:X.reload})}),!Z?.messages.length&&(0,I.jsx)(`div`,{className:`assistant-empty`,children:Q?.resumeSession?`已接入原生会话,发送消息继续。`:`在当前目录开始一段对话。`})]}),Z?.commands.filter(e=>e.state!==`succeeded`&&![`diff`,`history`].includes(e.kind)).slice(-3).map(e=>(0,I.jsxs)(`p`,{className:`computer-control-status`,role:`status`,children:[e.kind,` · `,Ue[e.state]??e.state,e.error?`:${e.error}`:``]},e.id)),(0,I.jsx)(c,{error:!0,children:T||X.error||Q?.error}),Q&&(0,I.jsx)(pe,{value:R,onChange:_e,label:`向本地 Agent 发送消息`,sendLabel:W?.capabilities.includes(`local-agent-queue-v1`)&&[`working`,`waiting`].includes(Q.state)?`加入队列`:`发送`,placeholder:Q.archived?`会话已归档`:`输入消息…`,disabled:Q.archived||!Ze,sendDisabled:N||Y.busy||Y.images.length>0&&!st,attachments:(0,I.jsxs)(I.Fragment,{children:[Y.preview(N),Y.images.length>0&&!st&&(0,I.jsx)(c,{children:`当前模型不支持图片,请切换模型或移除图片。`})]}),hasAttachments:Y.images.length>0,onFiles:st&&!N?e=>void Y.add(e):void 0,actions:(0,I.jsxs)(I.Fragment,{children:[st&&Y.picker(N||!Ze),(0,I.jsx)(Be,{session:Q,models:ot,busy:N,available:!!Ze,online:!!W?.online,commands:at,controls:it?.controls,draft:R,onInsert:e=>{rt(e.kind===`skill`?e:null),_e(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{Qe(()=>J(`web/local-agent-sessions/${Q.id}/settings`,P,{method:`PUT`,body:{expectedRevision:Q.revision,config:e}}))}})]}),onSubmit:t=>{t.preventDefault();let n=R.trim();if(!n&&!Y.images.length)return;let r=Y.images.map(e=>e.id),i=nt?.path&&n.startsWith(`$${nt.name}`)?[{name:nt.name,path:nt.path}]:void 0,a=JSON.stringify({session:Q.id,body:n,skills:i,images:r});V.current?.fingerprint!==a&&(V.current={fingerprint:a,id:e()});let o=V.current;Qe(async()=>{await J(`web/local-agent-sessions/${Q.id}/messages`,l(),{method:`POST`,body:{id:o.id,body:n,...r.length?{images:r}:{},...i?{skills:i}:{}}}),_e(e=>e.trim()===n?``:e),rt(null),Y.clear(),V.current===o&&(V.current=void 0)})}})]}):(0,I.jsxs)(`div`,{className:`assistant-empty`,children:[`尚未登记本地执行目录。`,(0,I.jsx)(`button`,{onClick:()=>ue(!0),children:`接入目录`})]})]})}export{H as Computers,he as t};
@@ -1 +0,0 @@
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}#workspace-diff{width:min(900px,100vw - 32px);max-width:calc(100vw - 32px)}.workspace-diff{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.workspace-diff p{margin:0}.workspace-diff-toolbar,.workspace-diff summary{justify-content:space-between;align-items:center;gap:16px;display:flex}.workspace-diff summary{cursor:pointer;padding:10px 0;font-size:13px}.workspace-diff summary span,.workspace-diff-path{overflow-wrap:anywhere}.workspace-diff summary small{white-space:nowrap;color:var(--color-muted)}.workspace-diff pre{background:var(--color-surface);border:1px solid var(--color-line);border-radius:6px;max-height:50vh;margin:0;padding:10px;font-size:12px;line-height:1.6;overflow:auto}.workspace-diff pre span{min-width:100%;display:block}.diff-added{color:#247944;background:#2a91531f}.diff-removed{color:#ac3434;background:#be3a3a1a}.diff-hunk{color:#566e9a}.session-images{flex-wrap:wrap;gap:8px;padding:6px 0;display:flex}.session-image{position:relative}.session-image img{object-fit:cover;border:1px solid var(--color-line);border-radius:8px;width:112px;height:88px;display:block}.session-image button{background:var(--color-surface);border-radius:50%;width:24px;height:24px;padding:3px;position:absolute;top:4px;right:4px}.session-image-file{display:none}.queued-message{flex-wrap:wrap;align-items:center;gap:8px;margin-top:5px;display:flex}.queued-message-actions{gap:8px;display:flex}.queued-message-actions button{min-height:26px;padding:2px 8px;font-size:12px}.queued-message-editor{gap:8px;width:100%;display:grid}.queued-message-editor textarea{resize:vertical;width:100%;min-height:80px}.computer-messages{width:100%;max-width:820px;margin:0 auto}.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-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%}.computer-tool{min-width:0;color:var(--color-muted);font-size:var(--text-sm);margin:10px 0}.computer-tool>summary{cursor:pointer;align-items:center;gap:8px;min-height:32px;padding:6px 0;list-style:none;display:flex}.computer-tool>summary::-webkit-details-marker{display:none}.computer-tool>summary>.icon{flex-shrink:0;width:12px;height:12px}.computer-tool[open]>summary>.icon{transform:rotate(90deg)}.computer-tool-label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.computer-tool-status{font-size:var(--text-xs);flex-shrink:0;gap:6px;display:flex}.computer-tool 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}.agent-logo{object-fit:contain;flex-shrink:0;width:24px;height:24px;padding:1px;display:block}.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%;font-size:var(--text-sm);flex-direction:column;flex-shrink:1;justify-content:center;align-items:flex-start;gap:4px;padding:10px 12px;font-weight:500;display:flex}.question-options button[aria-pressed=true]{border-color:var(--brand-orange);background:var(--color-accent-soft);color:var(--color-link)}.question-options button small{color:var(--color-muted);font-size:var(--text-xs);white-space:normal;font-weight:400;line-height:1.6}.question-options-described{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));width:100%;display:grid}.question-options-described button{justify-content:flex-start}.question-option-label{align-items:center;gap:8px;display:flex}.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-detail{white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;overflow:auto}.native-approval-options{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,216px);display:grid}.native-approval-options button{text-align:center;align-items:center}.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{padding:4px}.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{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;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}@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<=600px){.computers-layout{grid-template-rows:minmax(230px,32dvh) minmax(0,1fr)}.computers-layout .assistant-list.file-tree-pane{gap:0;display:flex}}.computer-create-scope{font-size:var(--text-sm);margin:0}
@@ -1 +0,0 @@
1
- import{E as e,S as t,_ as n,_t as r,a as i,b as a,c as o,d as s,f as c,g as l,gt as u,l as d,p as f,r as p,s as m,t as h,v as g}from"./Dropdown-BnYLBw2s.js";import{R as _,T as v,z as y}from"./index-D9m13C7l.js";import{t as b}from"./project-links-Dy6-B89_.js";import"./file-links-V3R--z0b.js";var x=u(),S=t();function C({className:e=``,...t}){return(0,S.jsx)(`button`,{type:`button`,...t,className:`pill-control ${e}`})}function w({className:e=``,...t}){return(0,S.jsx)(h,{...t,className:`pill-menu ${e}`})}var T=[{value:`time`,label:`按时间`,icon:`clock`},{value:`owner`,label:`按用户`,icon:`members`}],E=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function D({members:e,project:t,memberId:n}){let{request:s,projectId:l}=v(),u=`teammy-board-mine:${n}:${l}`,[d,m]=(0,x.useState)(()=>{try{return localStorage.getItem(u)===`true`}catch{return!1}}),h=`teammy-board-order:${n}:${l}`,[y,b]=(0,x.useState)(()=>{try{return localStorage.getItem(h)===`owner`?`owner`:`time`}catch{return`time`}}),D=T.find(e=>e.value===y),k=(0,x.useCallback)(e=>s(`tasks`,_,{signal:e}),[s]),A=g(k,3e3,a(l,`tasks`)),[M,N]=(0,x.useState)(),[P,F]=(0,x.useState)(!1),[I,L]=(0,x.useState)(Date.now);(0,x.useEffect)(()=>{let e=setInterval(()=>L(Date.now()),6e4);return()=>clearInterval(e)},[]);let R=A.data,z=R?.tasks.filter(e=>!d||e.owner===n)??[],B=new Set(e.map(e=>e.id));return(0,S.jsxs)(`div`,{className:`task-board`,children:[(0,S.jsx)(f,{title:t?.projectName.trim()?`${t.projectName.trim()}|工作看板`:`工作看板`,description:t?.description.trim()||``,children:(0,S.jsx)(`a`,{className:`task-board-home`,"data-testid":`home-link`,href:r(`/projects`),onClick:e=>{e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),history.pushState(null,``,r(`/projects`)),window.dispatchEvent(new PopStateEvent(`popstate`)))},"aria-label":`项目主页`,"data-tooltip":`项目主页`,children:(0,S.jsx)(p,{})})}),(0,S.jsxs)(`div`,{className:`task-board-toolbar`,role:`group`,"aria-label":`看板筛选与排序`,children:[(0,S.jsxs)(C,{"aria-pressed":d,"data-testid":`task-board-mine`,onClick:()=>{let e=!d;m(e),F(!1);try{localStorage.setItem(u,String(e))}catch{}},children:[(0,S.jsx)(o,{name:d?`enable`:`account`,size:`small`}),`只看我的`]}),(0,S.jsx)(w,{id:`task-board-sort-menu`,triggerId:`task-board-sort`,label:`任务排序:${D.label}`,routeKey:y,trigger:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)(o,{name:D.icon,size:`small`}),(0,S.jsx)(`span`,{children:D.label}),(0,S.jsx)(o,{name:`chevronDown`,size:`small`})]}),children:e=>T.map(t=>(0,S.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),b(t.value),F(!1);try{localStorage.setItem(h,t.value)}catch{}},children:[(0,S.jsx)(o,{name:t.icon,size:`small`}),(0,S.jsx)(`span`,{children:t.label}),y===t.value&&(0,S.jsx)(o,{name:`check`,size:`small`})]},t.value))})]}),(0,S.jsx)(c,{error:!0,children:A.error}),(0,S.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:E.filter(e=>e.status!==null||z.some(e=>e.status===null)).map(e=>{let t=z.filter(t=>t.status===e.status);t.sort((t,n)=>(y===`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`&&!P?t.slice(0,5):t;return(0,S.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,S.jsxs)(`h2`,{children:[(0,S.jsx)(`span`,{className:`lane-dot`}),e.label,(0,S.jsx)(i,{children:R?t.length:`—`})]}),(0,S.jsxs)(`div`,{className:`task-lane-content`,children:[t.length?n.map(e=>(0,S.jsx)(O,{task:e,memberIds:B,now:I,onEdit:()=>N(e),onSaved:()=>void A.reload()},e.id)):(0,S.jsx)(`p`,{className:`task-lane-empty`,children:A.error&&!R?`读取失败`:R?`暂无任务`:`读取中…`}),e.status===`completed`&&t.length>5&&(0,S.jsxs)(`button`,{type:`button`,className:`task-lane-expand`,"aria-expanded":P,onClick:()=>F(!P),children:[(0,S.jsx)(o,{name:P?`chevronUp`:`chevronDown`,size:`small`}),P?`收起`:`展开其余 ${t.length-5} 项`]})]})]},e.label)})}),M&&(0,S.jsx)(j,{task:M,onClose:()=>N(void 0),onSaved:()=>{N(void 0),A.reload()}},M.id)]})}function O({task:t,memberIds:i,onEdit:a,onSaved:s,now:u}){let{projectId:f,request:p}=v(),m=n(),[h,g]=(0,x.useState)(!1),[_,C]=(0,x.useState)(``);async function w(){if(!h){g(!0),C(``);try{await p(`tasks/${t.id}/correction`,y,{method:`PATCH`,signal:m,body:{needsConfirmation:!1,expectedRevision:t.revision}}),m.aborted||s()}catch(t){m.aborted||C(e(t))}finally{g(!1)}}}return(0,S.jsxs)(`details`,{className:`task-card`,"data-testid":`task-card`,"data-task-id":t.id,"data-owner":t.owner,"data-status":t.status??`unknown`,children:[(0,S.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,S.jsx)(`h3`,{children:t.title}),(0,S.jsxs)(`span`,{className:`task-card-meta`,children:[(0,S.jsx)(`small`,{title:t.owner,children:t.owner}),t.needsConfirmation&&(0,S.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,S.jsx)(o,{name:`attention`,size:`small`}),`需要确认`]}),t.status!==`completed`&&(0,S.jsx)(k,{since:t.statusSince,now:u})]})]}),(0,S.jsx)(d,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${t.title}`,"data-testid":`task-correct`,disabled:h,onClick:a}),(0,S.jsxs)(`div`,{className:`task-card-details`,children:[(0,S.jsx)(`h4`,{children:`目标`}),(0,S.jsx)(`p`,{children:t.goal?(0,S.jsx)(A,{value:t.goal,memberIds:i}):`目标未明确`}),(0,S.jsx)(`h4`,{children:`当前进展`}),(0,S.jsx)(`p`,{className:`task-progress`,children:(0,S.jsx)(A,{value:t.progress,memberIds:i})}),(0,S.jsx)(`div`,{className:`task-card-sources`,children:t.sources.map(e=>(0,S.jsxs)(`a`,{"data-testid":`task-source`,href:r(e.kind===`material`?`/projects/${f}/materials?id=${e.materialId}&revision=${e.revision}`:b(f,t.owner,e.path)),children:[(0,S.jsx)(o,{name:`file`,size:`small`}),(0,S.jsx)(`span`,{children:e.path})]},e.path))}),t.syncedAt&&(0,S.jsxs)(`small`,{children:[`资料同步于 `,(0,S.jsx)(l,{value:t.syncedAt})]}),t.needsConfirmation&&(0,S.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,S.jsx)(c,{error:!0,children:_}),(0,S.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:h,onClick:()=>void w(),children:h?`正在保存…`:`保存`})]})]})]})}function k({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,S.jsxs)(`span`,{className:`task-age${n>6048e5?` stale`:``}`,"data-testid":`task-age`,title:`进入当前状态:${new Date(e).toLocaleString(`zh-CN`)}`,"aria-label":`当前状态停留 ${i}`,children:[(0,S.jsx)(o,{name:`clock`,size:`small`}),i]})}function A({value:e,memberIds:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,S.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function j({task:t,onClose:r,onSaved:i}){let{request:a}=v(),o=n(),[l,u]=(0,x.useState)(t.title),[d,f]=(0,x.useState)(t.status??``),[p,h]=(0,x.useState)(t.goal??``),[g,_]=(0,x.useState)(t.progress),[b,C]=(0,x.useState)(!1),[w,T]=(0,x.useState)(``),D={...l===t.title?{}:{title:l},...d===(t.status??``)?{}:{status:d||null},...p===(t.goal??``)?{}:{goal:p||null},...g===t.progress?{}:{progress:g},...t.needsConfirmation?{needsConfirmation:!1}:{}};async function O(){if(!b&&Object.keys(D).length){C(!0),T(``);try{await a(`tasks/${t.id}/correction`,y,{method:`PATCH`,signal:o,body:{...D,expectedRevision:t.revision}}),o.aborted||i()}catch(t){o.aborted||T(e(t))}finally{C(!1)}}}return(0,S.jsx)(s,{id:`task-correction`,title:`纠正任务`,onClose:r,children:(0,S.jsxs)(`form`,{className:`stack`,"aria-busy":b,onSubmit:e=>{e.preventDefault(),O()},children:[(0,S.jsx)(m,{id:`task-title`,label:`标题`,children:(0,S.jsx)(`input`,{value:l,required:!0,onChange:e=>u(e.target.value)})}),(0,S.jsxs)(`fieldset`,{className:`task-status-field`,disabled:b,children:[(0,S.jsx)(`legend`,{children:`状态`}),(0,S.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:E.filter(e=>e.status!==null).map(e=>(0,S.jsxs)(`label`,{className:`task-status-choice`,children:[(0,S.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:d===e.status,onChange:()=>f(e.status)}),(0,S.jsx)(`span`,{children:e.label})]},e.status))}),(0,S.jsx)(`small`,{children:`待验收:任务成果已提交,等待验收或最终确认。`})]}),(0,S.jsx)(m,{id:`task-goal`,label:`目标`,children:(0,S.jsx)(`textarea`,{value:p,onChange:e=>h(e.target.value)})}),(0,S.jsx)(m,{id:`task-progress`,label:`当前进展`,children:(0,S.jsx)(`textarea`,{value:g,onChange:e=>_(e.target.value)})}),(0,S.jsx)(c,{error:!0,children:w}),(0,S.jsx)(`div`,{className:`row wrap`,children:(0,S.jsx)(`button`,{type:`submit`,className:`primary`,disabled:b||!Object.keys(D).length,"data-testid":`task-correction-save`,children:`保存`})})]})})}function M({members:e,config:t,memberId:n}){return(0,S.jsx)(D,{members:e,project:t,memberId:n})}export{M as Dashboard};