@teammy/server 0.2.6 → 0.2.8

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 +2005 -1631
  2. package/dist/native-pi-entry.js +4 -2
  3. package/dist/runtime/README.md +2 -2
  4. package/dist/runtime/shared/tools.json +1 -1
  5. package/dist/runtime/workflows/session-handoff/config.json +1 -1
  6. package/dist/runtime/workflows/session-handoff/prompt.md +1 -1
  7. package/dist/web/assets/Assistant-CYSa4zNi.js +1 -0
  8. package/dist/web/assets/Computers-4L48XuFg.js +4 -0
  9. package/dist/web/assets/Computers-_ugR447I.css +1 -0
  10. package/dist/web/assets/{Conversation-BY4zPO36.js → Conversation-BBWm5w-C.js} +1 -1
  11. package/dist/web/assets/Dashboard-Bdh00JcC.css +1 -0
  12. package/dist/web/assets/Dashboard-Ck2NsAbX.js +1 -0
  13. package/dist/web/assets/Files-CjNjoKS3.js +1 -0
  14. package/dist/web/assets/{Help-D_OceEX-.js → Help-DwUoT8ZM.js} +151 -60
  15. package/dist/web/assets/{HtmlPreview-BasLBM4N.js → HtmlPreview-B6aQIaMB.js} +1 -1
  16. package/dist/web/assets/{Markdown-B13Lfgpp.js → Markdown-DorC2YjE.js} +4 -4
  17. package/dist/web/assets/MessageComposer-DQBDG5yF.js +1 -0
  18. package/dist/web/assets/ResourceLibrary-104NuVRn.js +6 -0
  19. package/dist/web/assets/{ResourceLibrary-COmSSC8U.css → ResourceLibrary-BB5EdMby.css} +1 -1
  20. package/dist/web/assets/WorkspaceTree-B4FMRlCw.js +1 -0
  21. package/dist/web/assets/{file-links-CpTkSiiH.js → file-links-DnngiTbC.js} +1 -1
  22. package/dist/web/assets/index-DiR0ePCJ.js +66 -0
  23. package/dist/web/downloads/teammy-skill.zip +0 -0
  24. package/dist/web/index.html +1 -1
  25. package/package.json +1 -1
  26. package/dist/web/assets/Assistant-0ww2vlrH.js +0 -1
  27. package/dist/web/assets/Computers-Dc45R6Gl.css +0 -1
  28. package/dist/web/assets/Computers-yY5fO1ow.js +0 -3
  29. package/dist/web/assets/Dashboard-Cc8spFKR.js +0 -1
  30. package/dist/web/assets/Dashboard-DIunax0h.css +0 -1
  31. package/dist/web/assets/Files-DHGsGF_a.js +0 -1
  32. package/dist/web/assets/MessageComposer-8oeL6-cz.js +0 -1
  33. package/dist/web/assets/ResourceLibrary-BQ8s0LIx.js +0 -6
  34. package/dist/web/assets/WorkspaceTree-Dj0bClAO.js +0 -1
  35. package/dist/web/assets/index-BNGGPn0r.js +0 -66
@@ -0,0 +1 @@
1
+ import{$ as e,Tt as t,V as n}from"./index-DiR0ePCJ.js";var r=t(),i=e();function a({value:e,onChange:t,onSubmit:r,label:a,placeholder:s=`输入消息…`,disabled:c=!1,sendDisabled:l=!1,sendLabel:u=`发送`,actions:d,heading:f,inset:p=!1,plain:m=!1,attachments:h,hasAttachments:g=!1,onFiles:_}){let v=o(e),y=!c&&!l&&(!!e.trim()||g);return(0,i.jsxs)(`form`,{className:`message-composer${p?` message-composer-inset`:``}${m?` message-composer-plain`:``}`,onDragOver:e=>{_&&!c&&e.dataTransfer.types.includes(`Files`)&&e.preventDefault()},onDrop:e=>{_&&!c&&e.dataTransfer.files.length&&(e.preventDefault(),_(e.dataTransfer.files))},onSubmit:e=>{e.preventDefault(),y&&r(e)},children:[f&&(0,i.jsx)(`div`,{className:`message-composer-heading`,children:f}),h,(0,i.jsx)(`textarea`,{ref:v,value:e,onChange:e=>t(e.target.value),"aria-label":a,placeholder:s,disabled:c,onPaste:e=>{_&&!c&&e.clipboardData.files.length&&(e.preventDefault(),_(e.clipboardData.files))},rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),y&&e.currentTarget.form?.requestSubmit())}}),(0,i.jsxs)(`div`,{className:`message-composer-footer`,children:[d&&(0,i.jsx)(`div`,{className:`message-composer-actions`,children:d}),(0,i.jsx)(`button`,{type:`submit`,className:`primary message-send`,"aria-label":u,title:u,disabled:!y,children:(0,i.jsx)(n,{name:`send`,size:`small`})})]})]})}function o(e,t){let n=(0,r.useRef)(null);return(0,r.useLayoutEffect)(()=>{let e=n.current;if(!e)return;let r=()=>{t?.(e),e.style.height=`0px`,e.style.height=`${e.scrollHeight}px`};r();let i=e.clientWidth,a=new ResizeObserver(()=>{i!==e.clientWidth&&(i=e.clientWidth,r())});return a.observe(e),()=>a.disconnect()},[e,t]),n}export{o as n,a as t};
@@ -0,0 +1,6 @@
1
+ import{$ as e,B as t,Ct as n,Dt as r,Et as i,G as a,H as o,J as s,K as c,St as l,Tt as u,V as d,W as f,X as p,Y as m,Z as h,_ as g,_t as _,at as v,bt as y,dt as b,et as x,ft as S,gt as C,ht as w,lt as T,m as E,mt as D,nt as O,ot as k,p as A,pt as j,rt as M,st as N,ut as P,vt as F,wt as I,x as L,yt as R,z as ee}from"./index-DiR0ePCJ.js";import{n as z,r as B,t as V}from"./Markdown-DorC2YjE.js";import{t as H}from"./Conversation-BBWm5w-C.js";import{i as te,r as U}from"./WorkspaceTree-B4FMRlCw.js";import{n as W}from"./project-links-Dy6-B89_.js";import{t as G}from"./HtmlPreview-B6aQIaMB.js";function K(e){return I(S,e)}var q=u(),ne=R().regex(/^R\d{6,}$/),J=F({name:R().min(1),sha256:T,size:_().int().nonnegative()}),Y=l().refine(e=>/^https?:\/\//i.test(e),`Use an HTTP or HTTPS URL.`);F({operationId:n(),title:R().trim().default(``),text:R().optional(),url:Y.optional(),originals:D(J).default([])}).strict().refine(e=>!!e.text?.trim()||!!e.url||e.originals.length>0,`Provide text, a link or a file.`),F({expectedRevision:P,title:R().trim().min(1).optional(),url:Y.nullable().optional(),content:R().optional(),summary:R().optional(),sourceVersion:R().optional(),contentDate:R().optional(),originals:D(J).optional()}).strict();var X=F({id:ne,projectId:R(),title:R(),submittedBy:R(),createdAt:R(),revision:P,source:F({kind:j([`web`,`chat`,`group`]),url:R().nullable(),groupId:R().optional(),messageId:R().optional(),sourceVersion:R().optional(),contentDate:R().optional()}),originals:D(J),content:R().nullable(),summary:R().nullable(),state:j([`waiting`,`running`,`ready`,`failed`]),error:R().nullable(),url:R()}),re=F({materials:D(X),nextCursor:_().nullable()});F({query:R().trim().min(1),scope:j([`all`,`workspace`,`materials`]).default(`all`),materialId:ne.optional(),originalHash:T.optional(),after:R().default(``),limit:K().int().min(1).max(200).default(30)}).strict();var ie=F({items:D(F({key:R(),kind:j([`workspace`,`materials`]),title:R(),snippet:R(),url:R(),path:R()})),nextCursor:R().nullable()}),Z=e();function ae(e){let t=(e.content??``).trimStart().split(`
2
+ `);return t[0]?.replace(/^#\s+/,``).trim()===e.title.trim()&&t[0].startsWith(`# `)&&t.shift(),t.join(`
3
+ `).trimStart()}function oe(){let e=new URLSearchParams(location.search),t=e.get(`id`);return t?{id:t,...e.get(`original`)?{original:e.get(`original`)}:{},...e.get(`revision`)?{revision:e.get(`revision`)}:{}}:void 0}function se({active:e,onActivate:t,children:n}){let{request:s,projectId:c}=L(),[l,u]=(0,q.useState)(oe),[f,m]=(0,q.useState)(l),[_,v]=(0,q.useState)(()=>new Set(l?[l.id]:[])),[y,b]=(0,q.useState)(!1),[x,S]=(0,q.useState)(``),[C,w]=(0,q.useState)(``),[T,E]=(0,q.useState)(``),[D,k]=(0,q.useState)([]),[A,j]=(0,q.useState)(),[M,N]=(0,q.useState)(!1),[P,F]=(0,q.useState)(``),I=(0,q.useRef)(null),R=(0,q.useCallback)(e=>s(`materials`,re,{signal:e}),[s]),z=p(R,5e3,h(c,`materials`)),B=(0,q.useCallback)(e=>l?s(`materials/${encodeURIComponent(l.id)}${l.revision?`?revision=${encodeURIComponent(l.revision)}`:``}`,X,{signal:e}):Promise.resolve(null),[s,l?.id,l?.revision]),H=p(B,5e3),U=H.data?.id===l?.id?H.data:null,W=[...new Map([...D,...z.data?.materials??[],...U?[U]:[]].map(e=>[e.id,e])).values()].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||t.id.localeCompare(e.id)),G=A===void 0?z.data?.nextCursor:A;function K(e,n=``){t(),u(e),m(e),w(``),E(n),b(!1),v(t=>new Set([...t,e.id])),history.replaceState(null,``,i(`/projects/${c}/materials?${new URLSearchParams({...e})}`))}(0,q.useEffect)(()=>{let e=()=>{if(!r().endsWith(`/materials`))return;let e=oe();u(e),m(e),w(``),S(``),E(``),b(!1),e&&v(t=>new Set([...t,e.id]))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);async function ne(){if(G&&!M){N(!0),F(``);try{let e=await s(`materials?before=${G}`,re);k(t=>[...t,...e.materials]),j(e.nextCursor)}catch(e){F(O(e))}finally{N(!1)}}}let J=W.find(e=>e.id===f?.id),Y=J?.originals.find(e=>e.sha256===f?.original)?.name??J?.title??`当前资料`;function ie(){m(void 0),E(``),I.current?.focus()}let se=(0,Z.jsx)(o,{icon:`plus`,label:`新增资料`,onClick:()=>{t(),b(!0),F(``)}});return n({tree:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a,{error:!0,children:z.error||P}),z.data?W.length===0?(0,Z.jsx)(`p`,{className:`tree-status`,children:`暂无资料`}):(0,Z.jsx)(Z.Fragment,{children:W.map(t=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(g,{role:`treeitem`,"aria-level":1,"aria-expanded":_.has(t.id),"aria-selected":e&&!y&&l?.id===t.id&&!l.original,className:`tree-item tree-folder`,style:{"--tree-level":1},"data-testid":`material-folder`,title:t.title,onClick:()=>{let e=_.has(t.id);K({id:t.id}),e&&v(e=>{let n=new Set(e);return n.delete(t.id),n})},leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${_.has(t.id)?`expanded`:``}`,children:(0,Z.jsx)(d,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(d,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:t.title})]}),_.has(t.id)&&(0,Z.jsx)(`div`,{role:`group`,children:[...t.originals].sort((e,t)=>te(e.name,t.name)).map((n,r)=>(0,Z.jsxs)(g,{role:`treeitem`,"aria-level":2,"aria-selected":e&&!y&&l?.id===t.id&&l.original===n.sha256,className:`tree-item`,style:{"--tree-level":2},"data-testid":`material-original`,title:n.name,onClick:()=>K({id:t.id,original:n.sha256,...t.id===l?.id&&l.revision?{revision:l.revision}:{}}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(d,{name:`file`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:n.name})]},`${n.sha256}:${r}`))})]},t.id))}):(0,Z.jsx)(`p`,{className:`tree-status`,children:`加载中…`}),G&&(0,Z.jsx)(`button`,{className:`tree-action`,disabled:M,onClick:()=>void ne(),children:M?`加载中…`:`加载更多`})]}),reader:(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`资料内容与搜索`,children:[(0,Z.jsx)(`div`,{className:`session-reader-content`,children:y?(0,Z.jsx)(fe,{onCancel:()=>b(!1),onSaved:e=>{K({id:e}),z.reload()}}):C?(0,Z.jsx)(ce,{query:C,scope:f,onSelect:e=>K(e,C)},`${C}/${f?.id}/${f?.original}`):l?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a,{error:!0,children:H.error}),U?l.original?(0,Z.jsx)(le,{material:U,hash:l.original,highlight:T},`${U.id}:${l.original}`):(0,Z.jsxs)(`article`,{className:`material-body`,children:[(0,Z.jsx)(`h1`,{children:U.title}),l.revision&&(0,Z.jsx)(`button`,{className:`material-link`,onClick:()=>K({id:l.id}),children:`查看最新内容`}),!l.revision&&(U.state===`waiting`||U.state===`running`)?(0,Z.jsx)(`p`,{className:`muted`,role:`status`,children:`正在整理…`}):null,(0,Z.jsx)(a,{error:!0,children:U.error??``}),!l.revision&&U.state===`failed`&&(0,Z.jsx)(`button`,{onClick:()=>void s(`materials/${l.id}/retry`,X,{method:`POST`}).then(()=>H.reload()).catch(e=>F(O(e))),children:`重试整理`}),U.content?(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(V,{highlight:T,children:ae(U)})}):(0,Z.jsx)(`p`,{className:`muted`,children:`正文尚未整理,可以先查看左侧原件。`})]}):(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`})]}):(0,Z.jsx)(ee,{mascot:!0,title:`选择资料开始阅读`,description:`也可以在下方搜索资料内容。`})}),!y&&(0,Z.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`material-search-form`,onSubmit:e=>{e.preventDefault(),w(x.trim()),E(``)},children:[f&&(0,Z.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,title:`清除搜索范围`,"aria-label":`清除范围:${Y}`,onClick:ie,children:[(0,Z.jsxs)(`span`,{className:`scope-label`,children:[`搜索:`,Y]}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Z.jsx)(`input`,{ref:I,"aria-label":`搜索资料`,placeholder:`搜索资料内容`,value:x,onChange:e=>S(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!x&&f&&(e.preventDefault(),ie())}}),(C||x||T)&&(0,Z.jsx)(o,{icon:`close`,label:`清空搜索`,onClick:()=>{S(``),w(``),E(``),I.current?.focus()}}),(0,Z.jsx)(o,{icon:`search`,type:`submit`,label:`搜索`,disabled:!x.trim()})]})]})]}),actions:se,href:`/projects/${c}/materials${l&&!y?`?${new URLSearchParams({...l})}`:``}`})}function ce({query:e,scope:t,onSelect:n}){let{request:r}=L(),[i,o]=(0,q.useState)(``),s=(0,q.useCallback)(n=>r(`resources/search?${new URLSearchParams({query:e,scope:`materials`,after:i,...t?{materialId:t.id}:{},...t?.original?{originalHash:t.original}:{}})}`,ie,{signal:n}),[r,e,t?.id,t?.original,i]),c=p(s);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,children:[(0,Z.jsx)(a,{error:!0,children:c.error}),c.loading?(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}):c.data?.items.length===0?(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的资料`}):c.data?.items.map(t=>(0,Z.jsxs)(`button`,{className:`session-item`,"data-testid":`material-match`,onClick:()=>{let e=new URL(t.url,location.origin).searchParams;n({id:e.get(`id`),...e.get(`original`)?{original:e.get(`original`)}:{},...e.get(`revision`)?{revision:e.get(`revision`)}:{}})},children:[(0,Z.jsx)(`strong`,{children:t.title.replace(/^R\d+ · /,``)}),(0,Z.jsx)(`span`,{className:`session-excerpt`,children:(0,Z.jsx)(z,{value:B(t.snippet,e),query:e})})]},t.key)),c.data?.nextCursor&&(0,Z.jsx)(`button`,{disabled:c.loading,onClick:()=>o(c.data.nextCursor),children:`下一页`})]})}function le({material:e,hash:t,highlight:n}){let{projectId:r}=L(),s=e.originals.find(e=>e.sha256===t),c=i(`/api/v1/projects/${r}/materials/${e.id}/originals/${t}?revision=${e.revision}`),[l,u]=(0,q.useState)(!1),f=(0,q.useCallback)(async e=>{let t=await fetch(c,{signal:e});if(!t.ok)throw Error(`原件暂时无法读取。`);let n=await t.arrayBuffer();try{let e=new TextDecoder(`utf8`,{fatal:!0}).decode(n);return e.includes(`\0`)?null:e}catch{return null}},[c]),m=p(f,!1,h(r,`material-original`,t));if(!s)return(0,Z.jsx)(a,{error:!0,children:`找不到此原件。`});let g=/\.(md|markdown)$/i.test(s.name),_=/\.html?$/i.test(s.name);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`file-detail-header`,children:[(0,Z.jsx)(`span`,{className:`file-detail-path`,children:s.name}),(0,Z.jsxs)(`div`,{className:`toolbar-actions`,children:[(g||_)&&(0,Z.jsx)(o,{icon:l?`preview`:`code`,label:l?`切换为预览`:`切换为原文`,"aria-pressed":l,onClick:()=>u(!l)}),(0,Z.jsx)(`a`,{className:`icon-button`,"aria-label":`下载原件`,title:`下载原件`,href:c,download:s.name,children:(0,Z.jsx)(d,{name:`download`})})]})]}),(0,Z.jsx)(a,{error:!0,children:m.error}),m.loading?(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`}):m.data===null?(0,Z.jsx)(`p`,{className:`muted`,children:`此格式请下载后查看。`}):m.data!==void 0&&(0,Z.jsx)(`div`,{className:`preview-body${_&&!l?` preview-body-html`:``}`,"data-testid":`material-original-content`,children:_&&!l?(0,Z.jsx)(G,{url:c,name:s.name}):g&&!l?(0,Z.jsx)(`article`,{className:`markdown`,children:(0,Z.jsx)(V,{highlight:n,children:m.data})}):(0,Z.jsx)(`pre`,{className:`raw`,children:(0,Z.jsx)(z,{value:m.data,query:n})})})]})}function ue(e){if(e.kind===`text`){try{if([`http:`,`https:`].includes(new URL(e.text.trim()).protocol))return`link`}catch{}return`text`}let{name:t,type:n}=e.file;return n.startsWith(`image/`)||/\.(png|jpe?g|gif|webp|svg|heic|avif)$/i.test(t)?`imageFile`:/\.(csv|tsv|xlsx?|ods)$/i.test(t)?`spreadsheetFile`:/\.(json|ya?ml|xml|html?|css|[cm]?[jt]sx?|py|go|rs|sh|sql)$/i.test(t)?`codeFile`:n.startsWith(`text/`)||/\.(pdf|docx?|odt|rtf|md|txt)$/i.test(t)?`file`:`attachment`}function Q(e){try{return new URL(e.trim()).hostname}catch{return e.trim().split(`
4
+ `)[0]?.slice(0,80)||`文本`}}function de(e){try{return new URL(e.trim()).href}catch{return e.trim().split(`
5
+ `).slice(1).join(`
6
+ `)}}function fe({onSaved:e,onCancel:n}){let{request:r,projectId:s}=L(),[c,l]=(0,q.useState)([]),[u,p]=(0,q.useState)(),[m,h]=(0,q.useState)(!1),[g,_]=(0,q.useState)(``),v=(0,q.useRef)(null),y=(0,q.useRef)(M()),b=(0,q.useRef)(new Map);function x(e){l(e),y.current=M(),_(``)}async function S(){h(!0),_(``);try{let t=[];for(let[e,n]of c.entries()){let r=b.current.get(n.id);if(!r){let t=n.kind===`file`?n.file.name:`${Q(n.text)}.txt`,a=await fetch(i(`/api/v1/projects/${s}/materials/uploads`),{method:`POST`,headers:{"content-type":`application/octet-stream`,"x-teammy-web":`1`},body:n.kind===`file`?n.file:new Blob([n.text],{type:`text/plain`})}),o=await a.json();if(!a.ok)throw Error(o.error?.message??`第 ${e+1} 项上传失败。`);r={name:t,sha256:o.sha256,size:o.size},b.current.set(n.id,r)}t.push(r)}let n=c.length===1&&c[0]?.kind===`text`?c[0].text.trim():``,a;try{let e=new URL(n);[`http:`,`https:`].includes(e.protocol)&&(a=e.href)}catch{}e((await r(`materials`,X,{method:`POST`,body:{operationId:y.current,originals:t,...a?{url:a}:{}}})).id)}catch(e){_(O(e))}finally{h(!1)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{className:`material-form`,onSubmit:e=>{e.preventDefault(),S()},children:[(0,Z.jsx)(`h1`,{children:`新增资料`}),(0,Z.jsx)(`p`,{className:`muted`,children:`上传附件到项目,以便于Tim进行理解`}),(0,Z.jsx)(a,{error:!0,children:g}),(0,Z.jsxs)(`fieldset`,{disabled:m,children:[(0,Z.jsxs)(`div`,{className:`attachment-grid`,children:[c.map(e=>(0,Z.jsxs)(`article`,{className:`attachment-card`,"data-testid":`attachment-card`,children:[e.kind===`text`?(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-content`,"aria-label":`编辑:${Q(e.text)}`,onClick:()=>p({id:e.id,text:e.text}),children:[(0,Z.jsx)(d,{name:ue(e)}),(0,Z.jsx)(`span`,{className:`attachment-name`,children:Q(e.text)}),de(e.text)&&(0,Z.jsx)(`span`,{className:`attachment-excerpt`,children:de(e.text)})]}):(0,Z.jsxs)(`div`,{className:`attachment-content`,children:[(0,Z.jsx)(d,{name:ue(e)}),(0,Z.jsx)(`span`,{className:`attachment-name`,children:e.file.name})]}),(0,Z.jsx)(o,{className:`attachment-remove`,icon:`close`,label:`移除:${e.kind===`file`?e.file.name:Q(e.text)}`,onClick:()=>{b.current.delete(e.id),x(c.filter(t=>t.id!==e.id))}})]},e.id)),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>p({text:``}),children:[(0,Z.jsx)(d,{name:`addText`}),(0,Z.jsx)(`span`,{children:`添加文本/链接`})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>v.current?.click(),children:[(0,Z.jsx)(d,{name:`addFile`}),(0,Z.jsx)(`span`,{children:`添加文件`})]})]}),(0,Z.jsx)(`input`,{ref:v,type:`file`,multiple:!0,hidden:!0,"aria-label":`原始文件`,onChange:e=>{x([...c,...[...e.target.files??[]].map(e=>({id:M(),kind:`file`,file:e}))]),e.target.value=``}}),(0,Z.jsxs)(`div`,{className:`actions attachment-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:n,children:`取消`}),(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!c.length,children:m?`上传中…`:`提交资料`})]})]})]}),u&&(0,Z.jsx)(f,{id:`material-text-editor`,title:`添加文本/链接`,onClose:()=>p(void 0),children:(0,Z.jsxs)(`form`,{className:`stack`,onSubmit:e=>{if(e.preventDefault(),!u.text.trim())return;let t={id:u.id??M(),kind:`text`,text:u.text};b.current.delete(t.id),x(u.id?c.map(e=>e.id===u.id?t:e):[...c,t]),p(void 0)},children:[(0,Z.jsx)(t,{id:`material-attachment-text`,label:`文本或链接`,children:(0,Z.jsx)(`textarea`,{autoFocus:!0,rows:8,value:u.text,onChange:e=>p({...u,text:e.target.value}),placeholder:`粘贴文本或网页链接`})}),(0,Z.jsx)(`div`,{className:`actions`,children:(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!u.text.trim(),children:u.id?`保存`:`添加`})})]})})]})}var pe=j([`overview`,`handoff`]),me=F({title:R().trim().min(1),summary:R().trim().min(1)}),he=F({markdown:R().trim().min(1)}),ge=me.extend({sourceRevision:P,sourceHash:T,generatedAt:R(),stale:w()}),_e=F({kind:pe,status:j([`absent`,`queued`,`running`,`succeeded`,`failed`]),available:w(),currentRevision:P,sourceRevision:P.nullable(),stale:w(),result:y([me,he]).nullable(),generatedAt:R().nullable(),error:R().nullable()}),ve=j([`claude-code`,`codex`,`cursor`,`pi`,`dsh`]),ye=F({formatVersion:C(1),adapterVersion:C(1),agent:ve,nativeId:R().min(1).max(512),cwd:R().min(1).max(4096),messages:D(F({id:R().min(1).max(1024),role:j([`user`,`assistant`]),text:R().min(1),source:R().min(1).max(1024)}).strict())}).strict().refine(e=>new Set(e.messages.map(e=>e.id)).size===e.messages.length,`Duplicate message IDs.`);F({operationId:n(),sessionKey:T,parentRevision:P,blob:N}).strict(),F({revision:P,hash:T.nullable(),cleared:w()});var be=F({owner:b,sessionKey:T,agent:ve,nativeId:R(),cwd:R(),title:R(),revision:P,updatedAt:R(),messageCount:_().int().nonnegative(),blob:N,overview:ge.optional()}),xe=F({sessions:D(be),nextCursor:P.nullable()}),Se=F({totalSessions:_().int().nonnegative(),totalMessages:_().int().nonnegative(),memberCount:_().int().nonnegative(),updatedAt:R().nullable()});F({owner:b.optional(),sessionKey:T.optional()}).strict().refine(e=>!e.sessionKey||!!e.owner,`A session scope requires an owner.`);var Ce=F({matches:D(F({owner:b,sessionKey:T,revision:P,messageId:R(),source:j([`message`,`handoff`]).default(`message`),role:j([`user`,`assistant`]),snippet:R(),title:R()})),nextCursor:P.nullable()}),we=F({owner:b,key:T,revision:P.refine(e=>e>0).optional(),messageId:R().min(1).optional(),source:j([`message`,`handoff`]).optional()});function Te(e){let t=new URLSearchParams(e);if(![`owner`,`sessionKey`,`revision`,`messageId`].some(e=>t.has(e)))return{};let n=we.safeParse({owner:t.get(`owner`),key:t.get(`sessionKey`),...t.has(`revision`)?{revision:Number(t.get(`revision`))}:{},...t.has(`messageId`)?{messageId:t.get(`messageId`)}:{},...t.has(`source`)?{source:t.get(`source`)}:{}});return n.success?{target:n.data}:{error:`对话链接不完整或已损坏。`}}function Ee({members:e,refresh:t,selected:n,onOwner:r,onSession:i,level:a=1}){let[o,s]=(0,q.useState)(()=>new Set(n?.key?[n.owner]:[])),[c,l]=(0,q.useState)(e[0]?.id??``);return(0,Z.jsx)(`div`,{role:a===1?`tree`:`group`,"aria-label":`成员对话`,"data-testid":`session-tree`,onKeyDown:a===1?U:void 0,children:[...e].sort((e,t)=>te(e.id,t.id)).map(e=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(g,{type:`button`,role:`treeitem`,"aria-level":a,"aria-expanded":o.has(e.id),"aria-selected":n?.owner===e.id&&!n.key,className:`tree-item tree-folder`,style:{"--tree-level":a},tabIndex:c===e.id?0:-1,"data-testid":`session-owner`,"data-owner-id":e.id,onFocus:()=>l(e.id),onClick:()=>{s(t=>{let n=new Set(t);return n.has(e.id)?n.delete(e.id):n.add(e.id),n}),r(e.id)},leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${o.has(e.id)?`expanded`:``}`,children:(0,Z.jsx)(d,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(d,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,title:e.id,children:e.id})]}),o.has(e.id)&&(0,Z.jsx)(De,{level:a+1,owner:e.id,selected:n,onSession:i,focused:c,onFocus:l},`${e.id}/${t}`)]},e.id))})}function De({level:e,owner:t,selected:n,onSession:r,focused:i,onFocus:o}){let{request:s,projectId:c}=L(),l=(0,q.useCallback)(e=>s(`sessions?${new URLSearchParams({owner:t,limit:`50`,order:`updated`})}`,xe,{signal:e}),[t,s]),u=p(l,15e3,h(c,`session-tree`,t)),[f,m]=(0,q.useState)(),[_,y]=(0,q.useState)(!1),[b,x]=(0,q.useState)(``),S=(0,q.useRef)(null);(0,q.useEffect)(()=>()=>S.current?.abort(),[]);let C=f?f.nextCursor:u.data?.nextCursor;return(0,Z.jsxs)(`div`,{role:`group`,"aria-busy":u.loading||_,children:[(0,Z.jsx)(a,{error:!0,children:u.error||b}),u.error&&(0,Z.jsx)(`button`,{onClick:()=>void u.reload(),children:`重试`}),u.loading&&!u.data&&(0,Z.jsx)(`span`,{className:`tree-status`,role:`status`,children:`正在加载…`}),[...new Map([...f?.sessions??[],...u.data?.sessions??[]].map(e=>[e.sessionKey,e])).values()].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.sessionKey.localeCompare(t.sessionKey)).map(a=>(0,Z.jsxs)(g,{type:`button`,role:`treeitem`,"aria-level":e,"aria-selected":n?.owner===t&&n.key===a.sessionKey,className:`tree-item`,style:{"--tree-level":e},tabIndex:i===`${t}/${a.sessionKey}`?0:-1,"data-testid":`session-row`,"data-owner-id":t,"data-session-key":a.sessionKey,title:v(a.title||a.nativeId),onFocus:()=>o(`${t}/${a.sessionKey}`),onClick:()=>r({owner:t,key:a.sessionKey,title:a.title||a.nativeId}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(d,{name:`sessions`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:v(a.title||a.nativeId)})]},a.sessionKey)),C!=null&&(0,Z.jsx)(`button`,{className:`tree-action`,"data-testid":`session-tree-more`,disabled:_,onClick:async()=>{y(!0),x(``);let e=new AbortController;S.current=e;try{let n=await s(`sessions?${new URLSearchParams({owner:t,after:String(C),limit:`50`,order:`updated`})}`,xe,{signal:e.signal});m(e=>({sessions:[...e?.sessions??[],...n.sessions],nextCursor:n.nextCursor}))}catch(t){e.signal.aborted||x(O(t))}finally{e.signal.aborted||y(!1)}},children:`加载更多`})]})}function Oe({info:e,targeted:t=!1,highlight:n=``}){let[r,i]=(0,q.useState)(t),a=(0,q.useRef)(null);return(0,q.useEffect)(()=>{t&&a.current?.scrollIntoView({block:`center`})},[t]),(0,Z.jsxs)(`details`,{ref:a,open:r,className:`session-handoff`,onToggle:e=>i(e.currentTarget.open),children:[(0,Z.jsx)(`summary`,{children:`交接说明`}),r&&(0,Z.jsx)(ke,{info:e,revision:t?e.revision:void 0,highlight:n})]})}function ke({info:e,revision:t,highlight:n}){let{request:r}=L(),i=`sessions/${encodeURIComponent(e.owner)}/${e.sessionKey}`,o=(0,q.useCallback)(e=>r(`${i}/analysis/handoff${t===void 0?``:`?revision=${t}`}`,_e,{signal:e}),[r,i,t]),c=p(o,5e3),l=m(),[u,d]=(0,q.useState)(!1),[f,h]=(0,q.useState)(``),g=c.data,_=u||g?.status===`queued`||g?.status===`running`,v=g?.result&&`markdown`in g.result?g.result.markdown:void 0;return(0,Z.jsxs)(`div`,{className:`stack`,"data-testid":`session-handoff`,children:[(0,Z.jsx)(a,{error:!0,children:f||c.error}),c.loading&&!g&&(0,Z.jsx)(`small`,{role:`status`,children:`正在加载…`}),g&&(0,Z.jsxs)(`div`,{className:`inline-actions`,children:[g.status===`failed`&&t===void 0&&(0,Z.jsx)(`button`,{"data-testid":`session-handoff-generate`,disabled:_||!g.available,onClick:async()=>{d(!0),h(``);try{await r(`${i}/handoff`,_e,{method:`POST`,signal:l}),await c.reload()}catch(e){l.aborted||h(O(e))}finally{l.aborted||d(!1)}},children:_?`正在整理…`:`重试`}),!g.available&&(0,Z.jsx)(`small`,{children:`请先配置项目模型接入点`}),g.status===`failed`&&(0,Z.jsx)(`small`,{children:`整理未完成,可重试`}),g.available&&g.status!==`failed`&&(!v||g.stale||_)&&(0,Z.jsx)(`small`,{role:`status`,children:g.status===`running`||u?`正在整理…`:v?`对话已有新内容,等待自动更新…`:`等待自动整理…`}),g.currentRevision!==e.revision&&(0,Z.jsx)(`small`,{children:`交接说明使用最新对话;当前阅读的是历史原文`})]}),v&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`small`,{children:[`基于版本 `,g.sourceRevision,` · `,(0,Z.jsx)(s,{value:g.generatedAt})]}),(0,Z.jsx)(`div`,{className:`markdown`,"data-testid":`session-handoff-body`,children:(0,Z.jsx)(V,{highlight:n,children:v})})]})]})}function Ae({members:e,active:t,onActivate:n,children:s}){let{request:c,projectId:l,api:u}=L(),d=(0,q.useCallback)(async e=>{let[t,n]=await Promise.all([c(`sessions/stats`,Se,{signal:e}),u.members(e)]);return{...t,members:n.members}},[c,u]),f=p(d,!0,h(l,`session-stats`)),[m,g]=(0,q.useState)(``),[_,y]=(0,q.useState)(``),[b,x]=(0,q.useState)(0),[S]=(0,q.useState)(()=>Te(location.search)),[C,w]=(0,q.useState)(S.target),[T,E]=(0,q.useState)(S.target),[D,O]=(0,q.useState)(S.error??``),[j,M]=(0,q.useState)(``),N=(0,q.useRef)(null),P=C?.key?C.title?`搜索对话:${v(C.title)}`:`搜索当前对话`:C?`搜索:${C.owner} 的对话内容`:``,F=()=>{w(void 0),M(``),I(),N.current?.focus()};function I(){if(!T?.messageId)return;let{messageId:e,...t}=T;E(t),history.replaceState(null,``,i(W(l,t.owner,t.key,t)))}let R=(0,q.useCallback)(e=>{w(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t)},[]);(0,q.useEffect)(()=>{let e=()=>{if(!r().endsWith(`/sessions`))return;let e=Te(location.search);E(e.target),w(e.target),O(e.error??``),y(``),g(``),M(``)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let z=(e,t=``)=>{n(),E(e),w(e),y(``),M(t),O(``),history.replaceState(null,``,i(W(l,e.owner,e.key,e)))},B=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(a,{error:!0,children:f.error}),(0,Z.jsx)(Ee,{members:(f.data?.members??e).filter(e=>e.hasSessions),refresh:b,selected:t?C:void 0,level:2,onOwner:e=>{n(),w({owner:e}),E(void 0),y(``),M(``),O(``),history.replaceState(null,``,i(`/projects/${encodeURIComponent(l)}/sessions`))},onSession:z})]}),V=(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`对话内容与搜索`,children:[(0,Z.jsx)(A,{title:k.sessions,icon:`sessions`,count:(0,Z.jsx)(`span`,{"data-testid":`session-total`,children:f.data?.totalSessions??`—`}),children:(0,Z.jsx)(o,{icon:`refresh`,label:`刷新${k.sessions}`,"data-testid":`sessions-refresh`,disabled:f.loading,onClick:()=>{f.reload(),x(e=>e+1)}})}),(0,Z.jsx)(`div`,{className:`session-reader-content`,children:D?(0,Z.jsx)(a,{error:!0,children:D}):_?(0,Z.jsx)(je,{query:_,refresh:b,scope:{...C?{owner:C.owner}:{},...C?.key?{sessionKey:C.key}:{}},onSelect:e=>z(e,_)},`${_}/${C?.owner??``}/${C?.key??``}`):T?(0,Z.jsx)(Me,{selection:T,highlight:j,onLoaded:R,onLatest:()=>z({owner:T.owner,key:T.key})},`${T.owner}/${T.key}/${T.revision}/${T.source}/${b}`):(0,Z.jsx)(ee,{mascot:!0,title:`选择对话开始阅读`,description:`也可以在下方搜索会话库内容。`})}),(0,Z.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`session-search-form`,onSubmit:e=>{e.preventDefault(),y(m.trim()),M(``),O(``),x(e=>e+1)},children:[C&&(0,Z.jsxs)(`button`,{type:`button`,className:`search-scope-chip`,"data-testid":`session-search-scope`,title:`清除搜索范围`,"aria-label":`清除范围:${P}`,onClick:F,children:[(0,Z.jsx)(`span`,{className:`scope-label`,children:P}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Z.jsx)(`input`,{ref:N,"aria-label":`搜索对话`,"data-testid":`session-query`,value:m,maxLength:500,placeholder:`搜索会话库内容`,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!m&&C&&(e.preventDefault(),F())}}),(_||m||j)&&(0,Z.jsx)(o,{icon:`close`,label:`清空搜索`,"data-testid":`session-search-clear`,onClick:()=>{g(``),y(``),M(``),I(),N.current?.focus()}}),(0,Z.jsx)(o,{icon:`search`,type:`submit`,label:`搜索`,"data-testid":`session-search`,disabled:!m.trim()})]})]})]});return s({hasSelection:!!C,tree:B,reader:V,href:T?W(l,T.owner,T.key,T):`/projects/${l}/sessions`})}function je({query:e,refresh:t,scope:n,onSelect:r}){let{request:i}=L(),[o,s]=(0,q.useState)(0),c=(0,q.useCallback)(t=>i(`sessions/search?${new URLSearchParams({q:e,after:String(o),limit:`30`,order:`updated`,...n.owner?{owner:n.owner}:{},...n.sessionKey?{sessionKey:n.sessionKey}:{}})}`,Ce,{signal:t}),[i,e,o,t,n.owner,n.sessionKey]),l=p(c);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,"aria-busy":l.loading,children:[(0,Z.jsx)(a,{error:!0,children:l.error}),l.error&&(0,Z.jsx)(`button`,{onClick:()=>void l.reload(),children:`重试`}),l.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}),!l.loading&&l.data?.matches.map(t=>(0,Z.jsxs)(`button`,{className:`session-item`,"data-testid":`session-match`,"data-message-id":t.messageId,onClick:()=>r({owner:t.owner,key:t.sessionKey,revision:t.revision,messageId:t.messageId||void 0,source:t.source,title:t.title}),children:[(0,Z.jsx)(`strong`,{children:v(t.title)}),(0,Z.jsxs)(`small`,{children:[t.owner,` ·`,` `,t.source===`handoff`?`交接说明`:t.role===`user`?`用户`:`助手`]}),(0,Z.jsx)(`span`,{className:`session-excerpt`,children:(0,Z.jsx)(z,{value:B(t.snippet,e),query:e})})]},`${t.owner}:${t.sessionKey}:${t.revision}:${t.source}:${t.messageId}`)),!l.loading&&l.data?.matches.length===0&&(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的对话`}),l.data?.nextCursor!=null&&(0,Z.jsx)(`button`,{"data-testid":`sessions-next`,disabled:l.loading,onClick:()=>s(l.data.nextCursor),children:`下一页`}),o>0&&(0,Z.jsx)(`button`,{disabled:l.loading,onClick:()=>s(0),children:`返回第一页`})]})}function Me({selection:e,highlight:t,onLoaded:n,onLatest:r}){let{request:i}=L(),o=(0,q.useCallback)(async t=>{try{return await i(`sessions/${encodeURIComponent(e.owner)}/${e.key}${e.revision===void 0?``:`?revision=${e.revision}`}`,be,{signal:t})}catch(e){throw e instanceof x&&e.code===`SESSION_NOT_FOUND`?Error(`找不到这条对话或引用的版本,原链接可能已失效。`):e}},[i,e.owner,e.key,e.revision]),s=p(o,5e3);return(0,q.useEffect)(()=>{s.data&&n(s.data)},[s.data,n]),(0,Z.jsxs)(`section`,{className:`session-conversation stack`,"data-testid":`session-detail`,children:[(0,Z.jsx)(a,{error:!0,children:s.error}),s.error&&(0,Z.jsx)(`button`,{onClick:()=>void s.reload(),children:`重试`}),s.loading&&!s.data&&(0,Z.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),s.data&&(0,Z.jsx)(Ne,{info:s.data,messageId:e.messageId,handoff:e.source===`handoff`,highlight:t,pinned:e.revision!==void 0,onLatest:r},s.data.blob.sha256)]})}function Ne({info:e,messageId:t,handoff:n,highlight:r,pinned:o,onLatest:c}){let{readTextBlob:l,projectId:u}=L(),d=(0,q.useCallback)(async t=>ye.parse(JSON.parse(await l(e.blob,t))),[e.blob.sha256,e.blob.size]),f=p(d),m=(0,q.useRef)(null);return(0,q.useEffect)(()=>{f.data&&t&&m.current?.scrollIntoView({block:`center`})},[f.data,t]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`conversation-header`,children:[(0,Z.jsx)(`h2`,{className:`session-title`,children:v(e.title||e.nativeId)}),(0,Z.jsxs)(`p`,{children:[e.owner,` · `,e.agent,` · `,e.messageCount,` 条消息`]}),(0,Z.jsxs)(`small`,{children:[(0,Z.jsx)(s,{value:e.updatedAt}),o&&(0,Z.jsxs)(Z.Fragment,{children:[` `,`· 引用版本 `,e.revision,` ·`,` `,(0,Z.jsx)(`a`,{href:i(W(u,e.owner,e.sessionKey)),onClick:e=>{e.preventDefault(),c()},children:`查看最新`})]})]}),e.overview&&(0,Z.jsx)(`p`,{"data-testid":`session-summary`,children:e.overview.summary}),e.overview?.stale&&(0,Z.jsx)(`small`,{children:`摘要待更新`})]}),(0,Z.jsx)(Oe,{info:e,targeted:n,highlight:n?r:``}),(0,Z.jsx)(a,{error:!0,children:f.error}),f.error&&(0,Z.jsx)(`button`,{onClick:()=>void f.reload(),children:`重新读取`}),f.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),f.data&&(0,Z.jsxs)(Z.Fragment,{children:[t&&!f.data.messages.some(e=>e.id===t)&&(0,Z.jsx)(a,{children:`该版本中找不到引用的消息,已打开对话原文。`}),(0,Z.jsx)(`div`,{className:`session-messages`,children:f.data.messages.map(e=>(0,Z.jsx)(H,{mine:e.role===`user`,author:e.role===`user`?`用户`:`助手`,className:`session-message ${e.role} ${e.id===t?`matched`:``}`,"data-testid":`session-message`,"data-message-id":e.id,ref:e.id===t?m:void 0,children:(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(V,{highlight:r,children:e.text})})},e.id))})]})]})}var $=R().trim().min(1),Pe=F({id:n(),text:$,state:j([`draft`,`kept`]),revision:_().int().positive(),createdAt:R(),updatedAt:R()}),Fe=F({cards:D(Pe)});F({id:n(),text:$}).strict(),F({expectedRevision:_().int().positive(),text:$.optional(),action:j([`keep`,`discard`,`delete`]).optional()}).strict().refine(e=>e.text!==void 0||e.action!==void 0,`没有需要保存的修改。`),F({text:$}).strict();function Ie(){let{request:e,projectId:t}=L(),n=(0,q.useCallback)(t=>e(`memory`,Fe,{signal:t}),[e]),r=p(n,5e3,h(t,`memory`)),[i,s]=(0,q.useState)(null),[l,u]=(0,q.useState)({}),d=(0,q.useRef)(null),f=[...r.data?.cards??[]];for(let e of Object.values(l))f.some(t=>t.id===e.id)||f.push(e);if(r.data&&!d.current&&(d.current=[...f].sort((e,t)=>Number(t.state===`kept`)-Number(e.state===`kept`)).map(e=>e.id)),d.current){let e=new Map(d.current.map((e,t)=>[e,t]));for(let t of f)e.has(t.id)||(e.set(t.id,d.current.length),d.current.push(t.id));f.sort((t,n)=>e.get(t.id)-e.get(n.id))}return(0,Z.jsxs)(`section`,{className:`memory-page`,children:[(0,Z.jsx)(c,{title:`记忆`,children:(0,Z.jsx)(o,{icon:`plus`,label:`新增记忆`,disabled:!!i,onClick:()=>s(M())})}),(0,Z.jsx)(a,{error:!0,children:r.error}),!r.data&&r.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`}),(0,Z.jsxs)(`div`,{className:`memory-cards`,children:[i&&(0,Z.jsx)(Le,{id:i,onDone:()=>s(null),reload:r.reload},i),f.map(e=>(0,Z.jsx)(Le,{id:e.id,card:e,reload:r.reload,onEditing:t=>u(n=>{let r={...n};return t?r[e.id]=e:delete r[e.id],r})},e.id))]}),r.data&&f.length===0&&!i&&(0,Z.jsx)(`p`,{className:`memory-empty`,children:`暂无记忆`})]})}function Le({id:e,card:t,reload:n,onDone:r,onEditing:i}){let{request:s}=L(),[c,l]=(0,q.useState)(!t),[u,f]=(0,q.useState)(t?.text??``),[p,m]=(0,q.useState)(t?.revision),[h,g]=(0,q.useState)(!1),[_,v]=(0,q.useState)(``),y=(0,q.useRef)(!1),b=(0,q.useRef)(!1);function x(){b.current=!1,i?.(!0),f(t?.text??``),m(t?.revision),v(``),l(!0)}function S(){b.current=!0,l(!1),v(``),i?.(!1),r?.()}async function C(a){if(!y.current){if(!a&&t&&u===t.text)l(!1),i?.(!1);else if((!a||a===`keep`)&&!$.safeParse(c?u:t?.text).success)v(`请填写记忆内容。`);else{y.current=!0,g(!0),v(``);try{t?await s(`memory/${e}`,F({saved:w()}),{method:`PATCH`,body:{expectedRevision:c?p:t.revision,...a?{action:a}:{},...c&&a!==`discard`&&a!==`delete`?{text:u}:{}}}):await s(`memory`,Pe,{method:`POST`,body:{id:e,text:u}}),l(!1),await n(),i?.(!1),r?.()}catch(e){v(O(e)),await n()}finally{y.current=!1,g(!1)}}}}return(0,Z.jsxs)(`article`,{className:`memory-card`,"data-testid":`memory-card`,"data-memory-id":e,children:[(0,Z.jsx)(`span`,{className:`memory-status ${t?.state===`kept`?`is-kept`:``}`,role:`img`,"aria-label":t?.state===`kept`?`已保留`:`待确认`,children:(0,Z.jsx)(d,{name:t?.state===`kept`?`check`:`question`})}),(0,Z.jsxs)(`div`,{className:`memory-content`,children:[c?(0,Z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`记忆内容`,value:u,rows:2,disabled:h,onChange:e=>f(e.target.value),onBlur:e=>{b.current?b.current=!1:e.relatedTarget instanceof Element&&e.relatedTarget.closest(`.memory-actions`)||_||C()},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),S()),e.key===`Enter`&&!e.shiftKey&&(e.preventDefault(),C()))}}):(0,Z.jsx)(`button`,{type:`button`,className:`memory-text`,"aria-label":`编辑记忆:${t?.text??``}`,onClick:x,children:t?.text}),(0,Z.jsx)(a,{error:!0,children:_})]}),(0,Z.jsxs)(`div`,{className:`memory-actions`,onMouseDown:e=>{c&&e.preventDefault()},children:[(!t||t.state===`draft`)&&(0,Z.jsx)(o,{icon:`check`,label:t?`保留记忆`:`保存记忆`,disabled:h,onClick:()=>void C(t?`keep`:void 0)}),c&&t?.state===`kept`&&(0,Z.jsx)(o,{icon:`check`,label:`保存记忆`,disabled:h,onClick:()=>void C()}),(0,Z.jsx)(o,{icon:`close`,label:t?t.state===`draft`?`舍弃记忆`:`删除记忆`:`取消新增`,disabled:h,onClick:()=>{t?C(t.state===`draft`?`discard`:`delete`):S()}})]})]})}function Re({section:e,members:t,navigate:n}){let{projectId:r}=L(),[i,a]=(0,q.useState)(e===`sessions`);(0,q.useEffect)(()=>{e===`sessions`&&a(!0)},[e]);let o=t=>{e!==t&&n(`/projects/${r}/${t}`)};return(0,Z.jsx)(se,{active:e===`materials`,onActivate:()=>o(`materials`),children:r=>(0,Z.jsx)(Ae,{members:t,active:e===`sessions`,onActivate:()=>o(`sessions`),children:t=>(0,Z.jsx)(E,{reading:!0,className:`resource-library`,"data-testid":`materials-page`,label:`资料目录`,navigation:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(A,{title:`资料`,icon:`materials`,children:r.actions}),(0,Z.jsxs)(`div`,{role:`tree`,"aria-label":`项目资料`,onKeyDown:U,style:{"--tree-level":1},children:[(0,Z.jsxs)(g,{role:`treeitem`,"aria-level":1,"aria-selected":e===`memory`,className:`tree-item tree-folder`,"data-testid":`library-memory`,leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),onClick:()=>o(`memory`),children:[(0,Z.jsx)(d,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:`记忆`})]}),(0,Z.jsxs)(g,{role:`treeitem`,"aria-level":1,"aria-expanded":i,"aria-selected":e===`sessions`&&!t.hasSelection,className:`tree-item tree-folder`,"data-testid":`library-sessions`,leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${i?`expanded`:``}`,children:(0,Z.jsx)(d,{name:`chevron`,size:`small`})}),onClick:()=>{a(!i),e!==`sessions`&&n(t.href)},children:[(0,Z.jsx)(d,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:`会话库`})]}),(0,Z.jsx)(`div`,{hidden:!i,children:t.tree}),r.tree]})]}),children:e===`materials`?r.reader:e===`sessions`?t.reader:(0,Z.jsx)(`section`,{className:`session-reader`,"aria-label":`项目记忆`,children:(0,Z.jsx)(Ie,{})})})})})}export{Re as ResourceLibrary};
@@ -1 +1 @@
1
- .material-body h1{margin-top:0;font-size:24px}.material-form{max-width:780px}.material-form fieldset{border:0;margin:0;padding:0}.material-form textarea{resize:vertical}.material-link{color:var(--brand-orange);font-size:inherit;background:0 0;border:0;padding:0}.material-form>h1{margin:0 0 12px;font-size:28px}.material-form>p{margin:0 0 28px}.attachment-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;display:grid}.attachment-card,.attachment-add{border-radius:12px;min-width:0;min-height:174px}.attachment-card{border:1px solid var(--color-line);background:var(--color-surface);position:relative}.attachment-content{text-align:left;background:0 0;border:0;flex-direction:column;justify-content:flex-start;align-items:flex-start;gap:14px;width:100%;height:100%;padding:24px;font-weight:400;display:flex}.attachment-content>.icon{color:var(--color-muted);width:25px;height:25px}.attachment-name{-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;font-weight:500;line-height:1.5;display:-webkit-box;overflow:hidden}.attachment-excerpt{-webkit-line-clamp:2;overflow-wrap:anywhere;color:var(--color-muted);-webkit-box-orient:vertical;font-size:13px;line-height:1.6;display:-webkit-box;overflow:hidden}.attachment-remove{opacity:0;position:absolute;top:7px;right:7px}.attachment-card:hover .attachment-remove,.attachment-card:focus-within .attachment-remove{opacity:1}.attachment-add{border:1px dashed var(--color-line);background:var(--color-surface);color:var(--color-muted);flex-direction:column;justify-content:center;align-items:center;gap:16px;font-weight:400;display:flex}.attachment-add:hover{border-color:var(--brand-orange);color:var(--brand-orange)}.attachment-add>.icon{width:26px;height:26px}.attachment-actions{margin-top:28px}.session-handoff{padding-block:10px}.session-handoff>summary{cursor:pointer;font-weight:600}.session-handoff[open]>summary{margin-bottom:12px}.session-handoff button{min-height:28px;padding:4px 10px;font-size:12px}.memory-page{flex:1;width:100%;max-width:1000px;min-height:0;margin:0 auto;padding:0 8px 24px 0;overflow-y:auto}.memory-cards{gap:14px;display:grid}.memory-card{background:var(--color-surface,white);border:1px solid var(--color-line);border-radius:14px;align-items:flex-start;gap:16px;min-width:0;padding:20px 22px;display:flex}.memory-status{color:var(--color-muted);flex:none;padding-top:7px;display:flex}.memory-status.is-kept{color:var(--brand-orange)}.memory-content{flex:1;min-width:0}.memory-text{text-align:left;width:100%;font:inherit;overflow-wrap:anywhere;color:inherit;background:0 0;border:0;border-radius:0;padding:4px 0;line-height:1.7;display:block}.memory-text:hover{background:0 0}.memory-content textarea{resize:vertical;width:100%;min-height:64px;font:inherit;line-height:1.7;display:block}.memory-actions{flex-shrink:0;gap:4px;display:flex}.memory-empty{color:var(--color-muted);margin:24px 0}@media (width<=680px){.memory-card{gap:8px;padding:14px 12px}.memory-actions{gap:0}.memory-actions .icon-button{width:32px;height:32px;padding:4px}}
1
+ .material-body h1{margin-top:0;font-size:24px}.material-form{max-width:780px}.material-form fieldset{border:0;margin:0;padding:0}.material-form textarea{resize:vertical}.material-link{color:var(--brand-orange);font-size:inherit;background:0 0;border:0;padding:0}.material-form>h1{margin:0 0 12px;font-size:28px}.material-form>p{margin:0 0 28px}.attachment-grid{grid-template-columns:repeat(3,minmax(0,1fr));gap:16px;display:grid}.attachment-card,.attachment-add{border-radius:12px;min-width:0;min-height:174px}.attachment-card{border:1px solid var(--color-line);background:var(--color-surface);position:relative}.attachment-content{text-align:left;background:0 0;border:0;flex-direction:column;justify-content:flex-start;align-items:flex-start;gap:14px;width:100%;height:100%;padding:24px;font-weight:400;display:flex}.attachment-content>.icon{color:var(--color-muted);width:25px;height:25px}.attachment-name{-webkit-line-clamp:2;overflow-wrap:anywhere;-webkit-box-orient:vertical;font-weight:500;line-height:1.5;display:-webkit-box;overflow:hidden}.attachment-excerpt{-webkit-line-clamp:2;overflow-wrap:anywhere;color:var(--color-muted);-webkit-box-orient:vertical;font-size:13px;line-height:1.6;display:-webkit-box;overflow:hidden}.attachment-remove{opacity:0;position:absolute;top:7px;right:7px}.attachment-card:hover .attachment-remove,.attachment-card:focus-within .attachment-remove{opacity:1}.attachment-add{border:1px dashed var(--color-line);background:var(--color-surface);color:var(--color-muted);flex-direction:column;justify-content:center;align-items:center;gap:16px;font-weight:400;display:flex}.attachment-add:hover{border-color:var(--brand-orange);color:var(--brand-orange)}.attachment-add>.icon{width:26px;height:26px}.attachment-actions{margin-top:28px}.session-handoff{padding-block:10px}.session-handoff>summary{cursor:pointer;font-weight:600}.session-handoff[open]>summary{margin-bottom:12px}.session-handoff button{min-height:28px;padding:4px 10px;font-size:12px}.memory-page{flex:1;width:100%;max-width:1000px;min-height:0;margin:0 auto;padding:0 8px 24px 0;overflow-y:auto}.memory-cards{gap:14px;display:grid}.memory-card{background:var(--color-surface,white);border:1px solid var(--color-line);border-radius:14px;align-items:flex-start;gap:16px;min-width:0;padding:20px 22px;display:flex}.memory-status{color:var(--color-muted);flex:none;padding-top:7px;display:flex}.memory-status.is-kept{color:var(--brand-orange)}.memory-content{flex:1;min-width:0}.memory-text{text-align:left;width:100%;font:inherit;overflow-wrap:anywhere;white-space:pre-wrap;color:inherit;background:0 0;border:0;border-radius:0;padding:4px 0;line-height:1.7;display:block}.memory-text:hover{background:0 0}.memory-content textarea{resize:vertical;width:100%;min-height:64px;font:inherit;line-height:1.7;display:block}.memory-actions{flex-shrink:0;gap:4px;display:flex}.memory-empty{color:var(--color-muted);margin:24px 0}@media (width<=680px){.memory-card{gap:8px;padding:14px 12px}.memory-actions{gap:0}.memory-actions .icon-button{width:32px;height:32px;padding:4px}}
@@ -0,0 +1 @@
1
+ import{$ as e,G as t,Tt as n,V as r,X as i,Z as a,_ as o,d as s,f as c,l,nt as u,u as d,x as f}from"./index-DiR0ePCJ.js";var p=n(),m=new Intl.Collator(`zh-CN`,{numeric:!0,sensitivity:`base`});function h(e,t){return m.compare(e,t)||(e<t?-1:+(e>t))}var g=e();function _(e){let t=e.target.closest(`[role="treeitem"]`);if(!t)return;let n=[...e.currentTarget.querySelectorAll(`[role="treeitem"]`)].filter(e=>!e.closest(`[hidden]`)),r=n.indexOf(t),i=Number(t.getAttribute(`aria-level`)),a;switch(e.key){case`ArrowDown`:a=n[r+1];break;case`ArrowUp`:a=n[r-1];break;case`Home`:a=n[0];break;case`End`:a=n.at(-1);break;case`ArrowRight`:t.getAttribute(`aria-expanded`)===`false`?t.click():Number(n[r+1]?.getAttribute(`aria-level`))>i&&(a=n[r+1]);break;case`ArrowLeft`:t.getAttribute(`aria-expanded`)===`true`?t.click():a=n.slice(0,r).reverse().find(e=>Number(e.getAttribute(`aria-level`))<i);break;default:return}e.preventDefault(),a?.focus()}var v=(e,t)=>`${e}/${t}`,y=e=>({"--tree-level":e});function b({members:e,...t}){let[n,r]=(0,p.useState)(()=>`folder:${v(e.find(e=>e.hasFiles)?.id??`_project`,``)}`);return(0,g.jsx)(`div`,{role:`tree`,"aria-label":`工作区文件`,"data-testid":`workspace-tree`,onKeyDown:_,children:(0,g.jsx)(S,{owner:l,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function x({owner:e,path:t,level:n,context:i}){let a=i.expanded.has(v(e,t)),s=`folder:${v(e,t)}`;return(0,g.jsxs)(`div`,{role:`none`,children:[(0,g.jsxs)(o,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:y(n),"aria-label":t||e,"aria-level":n,"aria-expanded":a,"aria-selected":i.selected?.kind===`directory`&&i.selected.owner===e&&i.selected.path===t,tabIndex:i.focused===s?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>i.onFocus(s),onClick:()=>i.onToggle(e,t),leading:(0,g.jsx)(`span`,{className:`tree-chevron ${a?`expanded`:``}`,children:(0,g.jsx)(r,{name:`chevron`,size:`small`})}),children:[(0,g.jsx)(r,{name:`files`}),(0,g.jsx)(`span`,{className:`tree-name`,children:t.split(`/`).at(-1)||e})]}),a&&(0,g.jsx)(S,{owner:e,path:t,level:n+1,context:i})]})}function S({owner:e,path:n,level:l,context:m,members:_=[]}){let{api:b,projectId:S}=f(),C=(0,p.useCallback)(t=>b.tree(e,n,void 0,``,t),[e,n]),w=i(C,!1,a(S,`file-tree`,e,n)),[T,E]=(0,p.useState)(),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(``),j=(0,p.useRef)(null);(0,p.useEffect)(()=>()=>j.current?.abort(),[]);let M=T?.revision===w.data?.revision?T:void 0,N=M?M.nextCursor:w.data?.nextCursor;async function P(){if(!N||!w.data||D)return;O(!0),A(``);let t=new AbortController;j.current=t;try{let r=await b.tree(e,n,w.data.revision,N,t.signal);t.signal.aborted||E({...r,entries:[...M?.entries??[],...r.entries]})}catch(e){t.signal.aborted||A(u(e))}finally{t.signal.aborted||O(!1)}}let F=[...(w.data?.entries??[]).filter(e=>!s(e.path)),...(M?.entries??[]).filter(e=>!s(e.path))],I=m.revealed;if(I?.owner===e&&!s(I.path)&&(!n||I.path.startsWith(n+`/`))){let e=n?I.path.slice(n.length+1):I.path,t=e.indexOf(`/`),r=t<0?I.path:[n,e.slice(0,t)].filter(Boolean).join(`/`);F.some(e=>e.path===r)||F.push(t<0?{...I.file,kind:`file`}:{kind:`directory`,path:r})}let L=[...F.filter(t=>e!==`_project`||!d(t.path)).map(t=>({...t,owner:e})),..._.map(e=>({kind:`directory`,path:``,owner:e.id}))].sort((e,t)=>e.kind===t.kind?h(e.path.split(`/`).at(-1)||e.owner,t.path.split(`/`).at(-1)||t.owner):e.kind===`directory`?-1:1);return(0,g.jsxs)(`div`,{role:`group`,"aria-label":v(c(e)?`teamcontext`:e,n),"aria-busy":w.loading||D,children:[w.loading&&(0,g.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,g.jsx)(t,{error:!0,children:w.error||k}),w.error&&(0,g.jsx)(`button`,{className:`tree-action`,onClick:()=>void w.reload(),children:`重试`}),L.map(t=>t.kind===`directory`?(0,g.jsx)(x,{owner:t.owner,path:t.path,level:l,context:m},v(t.owner,t.path)):(0,g.jsxs)(o,{type:`button`,role:`treeitem`,className:`tree-item`,style:y(l),"aria-label":t.path,"aria-level":l,"aria-selected":m.selected?.kind===`file`&&m.selected.owner===e&&m.selected.path===t.path,tabIndex:m.focused===`file:${v(e,t.path)}`?0:-1,"data-testid":`file-row`,"data-owner-id":e,"data-file-path":t.path,onFocus:()=>m.onFocus(`file:${v(e,t.path)}`),onClick:()=>m.onSelect(e,t.path),leading:(0,g.jsx)(`span`,{className:`tree-chevron`}),children:[(0,g.jsx)(r,{name:`file`}),(0,g.jsx)(`span`,{className:`tree-name`,children:t.path.split(`/`).at(-1)})]},t.path)),N&&(0,g.jsx)(`button`,{className:`tree-action`,"data-testid":`files-load-more`,disabled:D,onClick:()=>void P(),children:D?`正在加载…`:`加载更多`})]})}export{h as i,v as n,_ as r,b as t};
@@ -1 +1 @@
1
- import{at as e}from"./index-BNGGPn0r.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};
1
+ import{ct as e}from"./index-DiR0ePCJ.js";function t(t,n){if(!n||/^(?:[a-z][a-z0-9+.-]*:|\/)/i.test(n))return null;try{let r=n.split(/[?#]/,1)[0],i=r?t.split(`/`).slice(0,-1):t.split(`/`);for(let e of r.split(`/`)){let t=decodeURIComponent(e);if(t&&t!==`.`){if(t===`..`){if(!i.length)return null;i.pop()}else{if(t.includes(`/`)||t.includes(`\\`))return null;i.push(t)}}}return{path:i.length?e.parse(i.join(`/`)):``,directory:r.endsWith(`/`),anchor:n.includes(`#`)?decodeURIComponent(n.slice(n.indexOf(`#`)+1)):``}}catch{return null}}export{t};