@teammy/server 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/dist/main.js +9198 -6986
- package/dist/project-pi-entry.js +60 -18
- package/dist/runtime/workflows/task-bootstrap/prompt.md +1 -1
- package/dist/web/assets/Assistant-CA1eprC5.js +1 -0
- package/dist/web/assets/Computers-B9XbkIvb.css +1 -0
- package/dist/web/assets/Computers-CVKzQb36.js +3 -0
- package/dist/web/assets/Conversation-B-uSxDxY.css +1 -0
- package/dist/web/assets/Conversation-BHkA10ok.js +1 -0
- package/dist/web/assets/Dashboard-DyX9HenR.css +1 -0
- package/dist/web/assets/Dashboard-lAD9sIHe.js +1 -0
- package/dist/web/assets/Files-IbfSqpuF.js +1 -0
- package/dist/web/assets/Help-DX51vBK7.css +1 -0
- package/dist/web/assets/Help-Sabz9D5O.js +578 -0
- package/dist/web/assets/{HtmlPreview-DcbwgS0C.js → HtmlPreview-wAvJBEw9.js} +1 -1
- package/dist/web/assets/{Markdown-hcMXu8Z6.js → Markdown-D_iBpZGz.js} +4 -4
- package/dist/web/assets/MessageComposer-DavJdQPa.css +1 -0
- package/dist/web/assets/MessageComposer-o8jlavYg.js +1 -0
- package/dist/web/assets/{Materials-CK-mbNmo.css → ResourceLibrary-COmSSC8U.css} +1 -1
- package/dist/web/assets/ResourceLibrary-VqGI1ZHy.js +6 -0
- package/dist/web/assets/WorkspaceTree-CgICKzbo.js +1 -0
- package/dist/web/assets/file-links-CCIRf9ju.js +1 -0
- package/dist/web/assets/index-DD447Vev.js +66 -0
- package/dist/web/assets/index-u4kRdqRX.css +1 -0
- package/dist/web/assets/workflow-DM6NUqoB.svg +111 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +2 -2
- package/package.json +1 -1
- package/dist/web/assets/Assistant-C7QfFYLo.css +0 -1
- package/dist/web/assets/Assistant-Drm0mOLL.js +0 -1
- package/dist/web/assets/Dashboard-C6aBw_W-.css +0 -1
- package/dist/web/assets/Dashboard-DRhlMd50.js +0 -1
- package/dist/web/assets/Files-BP2rAhTa.js +0 -1
- package/dist/web/assets/Materials-CTSi5rOS.js +0 -6
- package/dist/web/assets/Memory-C-z-5rpe.css +0 -1
- package/dist/web/assets/Memory-H9tRDj1a.js +0 -1
- package/dist/web/assets/Sessions-BwXwXx6i.css +0 -1
- package/dist/web/assets/Sessions-CvUoOrHZ.js +0 -1
- package/dist/web/assets/WorkspaceTree-D52TBZvy.js +0 -1
- package/dist/web/assets/file-links-QvRdAx7G.js +0 -1
- package/dist/web/assets/index-Bb8MF7Vk.js +0 -66
- package/dist/web/assets/index-Swfty9kO.css +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.message-composer{background:var(--color-surface);border:1px solid var(--color-line);border-radius:var(--radius-lg);flex-direction:column;flex:none;align-items:stretch;gap:12px;min-width:0;margin:0 28px 28px;padding:12px;display:flex}.message-composer:focus-within{border-color:var(--color-muted)}.message-composer textarea{width:100%;min-width:0;box-shadow:none;resize:none;background:0 0;border:0;min-height:40px;max-height:min(220px,28dvh);padding:8px;line-height:24px;overflow-y:auto}.message-composer textarea:focus{box-shadow:none;outline:none}.message-composer-footer,.message-composer-actions{align-items:center;gap:8px;display:flex}.message-composer-footer{justify-content:flex-end}.message-composer-actions{flex-wrap:nowrap;gap:6px;min-width:0;margin-right:auto}.message-composer-actions .icon-button{width:32px;height:32px;min-height:32px;color:var(--color-muted);padding:7px}.message-composer-actions .icon-button:hover,.message-composer-actions .icon-button[aria-pressed=true]{color:var(--color-text);background:var(--color-soft)}.message-send{border-radius:50%;flex:0 0 32px;place-items:center;width:32px;height:32px;min-height:32px;padding:0;display:grid}.message-composer-heading input{width:100%}@media (width<=900px){.message-composer{margin:0 16px 16px}}@media (width<=600px){.message-composer{gap:4px;margin:0 8px 12px;padding:6px}}.message-composer-inset{margin:0}.message-composer-plain{background:0 0;border:0;border-radius:0;gap:16px;padding:0}.message-composer-plain .topic-title{border:0;border-bottom:1px solid var(--color-line);box-shadow:none;font-size:var(--text-lg);background:0 0;border-radius:0;padding:8px 0;font-weight:600}.message-composer-plain textarea{min-height:120px;padding:0}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as e,N as t,_t as n}from"./index-DD447Vev.js";var r=n(),i=e();function a({value:e,onChange:n,onSubmit:r,label:a,placeholder:s=`输入消息…`,disabled:c=!1,sendDisabled:l=!1,sendLabel:u=`发送`,actions:d,heading:f,inset:p=!1,plain:m=!1}){let h=o(e),g=!c&&!l&&!!e.trim();return(0,i.jsxs)(`form`,{className:`message-composer${p?` message-composer-inset`:``}${m?` message-composer-plain`:``}`,onSubmit:e=>{e.preventDefault(),g&&r(e)},children:[f&&(0,i.jsx)(`div`,{className:`message-composer-heading`,children:f}),(0,i.jsx)(`textarea`,{ref:h,value:e,onChange:e=>n(e.target.value),"aria-label":a,placeholder:s,disabled:c,rows:1,onKeyDown:e=>{e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),g&&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:!g,children:(0,i.jsx)(t,{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};
|
|
@@ -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}
|
|
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}}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{$ as e,B as t,G as n,H as r,I as i,J as a,K as o,L as s,M as c,N as l,P as u,Q as d,R as f,U as p,V as m,Y as h,Z as g,_t as _,at as v,ct as y,d as b,dt as x,f as S,ft as C,gt as w,h as T,ht as E,it as D,j as ee,lt as O,mt as k,nt as A,ot as j,rt as M,st as N,tt as P,ut as F,vt as I,y as L,yt as te}from"./index-DD447Vev.js";import{n as R,r as z,t as B}from"./Markdown-D_iBpZGz.js";import{t as V}from"./Conversation-BHkA10ok.js";import{i as ne,r as H}from"./WorkspaceTree-CgICKzbo.js";import{n as U}from"./project-links-Dy6-B89_.js";import{t as W}from"./HtmlPreview-wAvJBEw9.js";function G(e){return w(D,e)}var K=_(),q=x().regex(/^R\d{6,}$/),J=F({name:x().min(1),sha256:P,size:O().int().nonnegative()}),Y=k().refine(e=>/^https?:\/\//i.test(e),`Use an HTTP or HTTPS URL.`);F({operationId:E(),title:x().trim().default(``),text:x().optional(),url:Y.optional(),originals:j(J).default([])}).strict().refine(e=>!!e.text?.trim()||!!e.url||e.originals.length>0,`Provide text, a link or a file.`),F({expectedRevision:A,title:x().trim().min(1).optional(),url:Y.nullable().optional(),content:x().optional(),summary:x().optional(),sourceVersion:x().optional(),contentDate:x().optional(),originals:j(J).optional()}).strict();var X=F({id:q,projectId:x(),title:x(),submittedBy:x(),createdAt:x(),revision:A,source:F({kind:v([`web`,`chat`,`group`]),url:x().nullable(),groupId:x().optional(),messageId:x().optional(),sourceVersion:x().optional(),contentDate:x().optional()}),originals:j(J),content:x().nullable(),summary:x().nullable(),state:v([`waiting`,`running`,`ready`,`failed`]),error:x().nullable(),url:x()}),re=F({materials:j(X),nextCursor:O().nullable()});F({query:x().trim().min(1),scope:v([`all`,`workspace`,`materials`]).default(`all`),materialId:q.optional(),originalHash:P.optional(),after:x().default(``),limit:G().int().min(1).max(200).default(30)}).strict();var ie=F({items:j(F({key:x(),kind:v([`workspace`,`materials`]),title:x(),snippet:x(),url:x(),path:x()})),nextCursor:x().nullable()}),Z=n();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:i,projectId:o}=L(),[c,d]=(0,K.useState)(oe),[f,m]=(0,K.useState)(c),[h,g]=(0,K.useState)(()=>new Set(c?[c.id]:[])),[_,v]=(0,K.useState)(!1),[y,b]=(0,K.useState)(``),[x,S]=(0,K.useState)(``),[C,w]=(0,K.useState)(``),[E,D]=(0,K.useState)([]),[O,k]=(0,K.useState)(),[A,j]=(0,K.useState)(!1),[M,N]=(0,K.useState)(``),P=(0,K.useRef)(null),F=(0,K.useCallback)(e=>i(`materials`,re,{signal:e}),[i]),R=r(F,5e3,p(o,`materials`)),z=(0,K.useCallback)(e=>c?i(`materials/${encodeURIComponent(c.id)}${c.revision?`?revision=${encodeURIComponent(c.revision)}`:``}`,X,{signal:e}):Promise.resolve(null),[i,c?.id,c?.revision]),V=r(z,5e3),H=V.data?.id===c?.id?V.data:null,U=[...new Map([...E,...R.data?.materials??[],...H?[H]:[]].map(e=>[e.id,e])).values()].sort((e,t)=>t.createdAt.localeCompare(e.createdAt)||t.id.localeCompare(e.id)),W=O===void 0?R.data?.nextCursor:O;function G(e,n=``){t(),d(e),m(e),S(``),w(n),v(!1),g(t=>new Set([...t,e.id])),history.replaceState(null,``,I(`/projects/${o}/materials?${new URLSearchParams({...e})}`))}(0,K.useEffect)(()=>{let e=()=>{if(!te().endsWith(`/materials`))return;let e=oe();d(e),m(e),S(``),b(``),w(``),v(!1),e&&g(t=>new Set([...t,e.id]))};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);async function q(){if(W&&!A){j(!0),N(``);try{let e=await i(`materials?before=${W}`,re);D(t=>[...t,...e.materials]),k(e.nextCursor)}catch(e){N(a(e))}finally{j(!1)}}}let J=U.find(e=>e.id===f?.id),Y=J?.originals.find(e=>e.sha256===f?.original)?.name??J?.title??`当前资料`;function ie(){m(void 0),w(``),P.current?.focus()}let se=(0,Z.jsx)(u,{icon:`plus`,label:`新增资料`,onClick:()=>{t(),v(!0),N(``)}});return n({tree:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{error:!0,children:R.error||M}),R.data?U.length===0?(0,Z.jsx)(`p`,{className:`tree-status`,children:`暂无资料`}):(0,Z.jsx)(Z.Fragment,{children:U.map(t=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(T,{role:`treeitem`,"aria-level":1,"aria-expanded":h.has(t.id),"aria-selected":e&&!_&&c?.id===t.id&&!c.original,className:`tree-item tree-folder`,style:{"--tree-level":1},"data-testid":`material-folder`,title:t.title,onClick:()=>{let e=h.has(t.id);G({id:t.id}),e&&g(e=>{let n=new Set(e);return n.delete(t.id),n})},leading:(0,Z.jsx)(`span`,{className:`tree-chevron ${h.has(t.id)?`expanded`:``}`,children:(0,Z.jsx)(l,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(l,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:t.title})]}),h.has(t.id)&&(0,Z.jsx)(`div`,{role:`group`,children:[...t.originals].sort((e,t)=>ne(e.name,t.name)).map((n,r)=>(0,Z.jsxs)(T,{role:`treeitem`,"aria-level":2,"aria-selected":e&&!_&&c?.id===t.id&&c.original===n.sha256,className:`tree-item`,style:{"--tree-level":2},"data-testid":`material-original`,title:n.name,onClick:()=>G({id:t.id,original:n.sha256,...t.id===c?.id&&c.revision?{revision:c.revision}:{}}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(l,{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:`加载中…`}),W&&(0,Z.jsx)(`button`,{className:`tree-action`,disabled:A,onClick:()=>void q(),children:A?`加载中…`:`加载更多`})]}),reader:(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`资料内容与搜索`,children:[(0,Z.jsx)(`div`,{className:`session-reader-content`,children:_?(0,Z.jsx)(fe,{onCancel:()=>v(!1),onSaved:e=>{G({id:e}),R.reload()}}):x?(0,Z.jsx)(ce,{query:x,scope:f,onSelect:e=>G(e,x)},`${x}/${f?.id}/${f?.original}`):c?(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{error:!0,children:V.error}),H?c.original?(0,Z.jsx)(le,{material:H,hash:c.original,highlight:C},`${H.id}:${c.original}`):(0,Z.jsxs)(`article`,{className:`material-body`,children:[(0,Z.jsx)(`h1`,{children:H.title}),c.revision&&(0,Z.jsx)(`button`,{className:`material-link`,onClick:()=>G({id:c.id}),children:`查看最新内容`}),!c.revision&&(H.state===`waiting`||H.state===`running`)?(0,Z.jsx)(`p`,{className:`muted`,role:`status`,children:`正在整理…`}):null,(0,Z.jsx)(s,{error:!0,children:H.error??``}),!c.revision&&H.state===`failed`&&(0,Z.jsx)(`button`,{onClick:()=>void i(`materials/${c.id}/retry`,X,{method:`POST`}).then(()=>V.reload()).catch(e=>N(a(e))),children:`重试整理`}),H.content?(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(B,{highlight:C,children:ae(H)})}):(0,Z.jsx)(`p`,{className:`muted`,children:`正文尚未整理,可以先查看左侧原件。`})]}):(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`})]}):(0,Z.jsx)(ee,{mascot:!0,title:`选择资料开始阅读`,description:`也可以在下方搜索资料内容。`})}),!_&&(0,Z.jsxs)(`form`,{className:`session-search-dock`,"data-testid":`material-search-form`,onSubmit:e=>{e.preventDefault(),S(y.trim()),w(``)},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:P,"aria-label":`搜索资料`,placeholder:`搜索资料内容`,value:y,onChange:e=>b(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!y&&f&&(e.preventDefault(),ie())}}),(x||y||C)&&(0,Z.jsx)(u,{icon:`close`,label:`清空搜索`,onClick:()=>{b(``),S(``),w(``),P.current?.focus()}}),(0,Z.jsx)(u,{icon:`search`,type:`submit`,label:`搜索`,disabled:!y.trim()})]})]})]}),actions:se,href:`/projects/${o}/materials${c&&!_?`?${new URLSearchParams({...c})}`:``}`})}function ce({query:e,scope:t,onSelect:n}){let{request:i}=L(),[a,o]=(0,K.useState)(``),c=(0,K.useCallback)(n=>i(`resources/search?${new URLSearchParams({query:e,scope:`materials`,after:a,...t?{materialId:t.id}:{},...t?.original?{originalHash:t.original}:{}})}`,ie,{signal:n}),[i,e,t?.id,t?.original,a]),l=r(c);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,children:[(0,Z.jsx)(s,{error:!0,children:l.error}),l.loading?(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}):l.data?.items.length===0?(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的资料`}):l.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)(R,{value:z(t.snippet,e),query:e})})]},t.key)),l.data?.nextCursor&&(0,Z.jsx)(`button`,{disabled:l.loading,onClick:()=>o(l.data.nextCursor),children:`下一页`})]})}function le({material:e,hash:t,highlight:n}){let{projectId:i}=L(),a=e.originals.find(e=>e.sha256===t),o=I(`/api/v1/projects/${i}/materials/${e.id}/originals/${t}?revision=${e.revision}`),[c,d]=(0,K.useState)(!1),f=(0,K.useCallback)(async e=>{let t=await fetch(o,{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}},[o]),m=r(f,!1,p(i,`material-original`,t));if(!a)return(0,Z.jsx)(s,{error:!0,children:`找不到此原件。`});let h=/\.(md|markdown)$/i.test(a.name),g=/\.html?$/i.test(a.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:a.name}),(0,Z.jsxs)(`div`,{className:`toolbar-actions`,children:[(h||g)&&(0,Z.jsx)(u,{icon:c?`preview`:`code`,label:c?`切换为预览`:`切换为原文`,"aria-pressed":c,onClick:()=>d(!c)}),(0,Z.jsx)(`a`,{className:`icon-button`,"aria-label":`下载原件`,title:`下载原件`,href:o,download:a.name,children:(0,Z.jsx)(l,{name:`download`})})]})]}),(0,Z.jsx)(s,{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${g&&!c?` preview-body-html`:``}`,"data-testid":`material-original-content`,children:g&&!c?(0,Z.jsx)(W,{url:o,name:a.name}):h&&!c?(0,Z.jsx)(`article`,{className:`markdown`,children:(0,Z.jsx)(B,{highlight:n,children:m.data})}):(0,Z.jsx)(`pre`,{className:`raw`,children:(0,Z.jsx)(R,{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:t}){let{request:n,projectId:r}=L(),[o,d]=(0,K.useState)([]),[f,p]=(0,K.useState)(),[m,g]=(0,K.useState)(!1),[_,v]=(0,K.useState)(``),y=(0,K.useRef)(null),b=(0,K.useRef)(h()),x=(0,K.useRef)(new Map);function S(e){d(e),b.current=h(),v(``)}async function C(){g(!0),v(``);try{let t=[];for(let[e,n]of o.entries()){let i=x.current.get(n.id);if(!i){let t=n.kind===`file`?n.file.name:`${Q(n.text)}.txt`,a=await fetch(I(`/api/v1/projects/${r}/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} 项上传失败。`);i={name:t,sha256:o.sha256,size:o.size},x.current.set(n.id,i)}t.push(i)}let i=o.length===1&&o[0]?.kind===`text`?o[0].text.trim():``,a;try{let e=new URL(i);[`http:`,`https:`].includes(e.protocol)&&(a=e.href)}catch{}e((await n(`materials`,X,{method:`POST`,body:{operationId:b.current,originals:t,...a?{url:a}:{}}})).id)}catch(e){v(a(e))}finally{g(!1)}}return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`form`,{className:`material-form`,onSubmit:e=>{e.preventDefault(),C()},children:[(0,Z.jsx)(`h1`,{children:`新增资料`}),(0,Z.jsx)(`p`,{className:`muted`,children:`上传附件到项目,以便于Tim进行理解`}),(0,Z.jsx)(s,{error:!0,children:_}),(0,Z.jsxs)(`fieldset`,{disabled:m,children:[(0,Z.jsxs)(`div`,{className:`attachment-grid`,children:[o.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)(l,{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)(l,{name:ue(e)}),(0,Z.jsx)(`span`,{className:`attachment-name`,children:e.file.name})]}),(0,Z.jsx)(u,{className:`attachment-remove`,icon:`close`,label:`移除:${e.kind===`file`?e.file.name:Q(e.text)}`,onClick:()=>{x.current.delete(e.id),S(o.filter(t=>t.id!==e.id))}})]},e.id)),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>p({text:``}),children:[(0,Z.jsx)(l,{name:`addText`}),(0,Z.jsx)(`span`,{children:`添加文本/链接`})]}),(0,Z.jsxs)(`button`,{type:`button`,className:`attachment-add`,onClick:()=>y.current?.click(),children:[(0,Z.jsx)(l,{name:`addFile`}),(0,Z.jsx)(`span`,{children:`添加文件`})]})]}),(0,Z.jsx)(`input`,{ref:y,type:`file`,multiple:!0,hidden:!0,"aria-label":`原始文件`,onChange:e=>{S([...o,...[...e.target.files??[]].map(e=>({id:h(),kind:`file`,file:e}))]),e.target.value=``}}),(0,Z.jsxs)(`div`,{className:`actions attachment-actions`,children:[(0,Z.jsx)(`button`,{type:`button`,onClick:t,children:`取消`}),(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!o.length,children:m?`上传中…`:`提交资料`})]})]})]}),f&&(0,Z.jsx)(i,{id:`material-text-editor`,title:`添加文本/链接`,onClose:()=>p(void 0),children:(0,Z.jsxs)(`form`,{className:`stack`,onSubmit:e=>{if(e.preventDefault(),!f.text.trim())return;let t={id:f.id??h(),kind:`text`,text:f.text};x.current.delete(t.id),S(f.id?o.map(e=>e.id===f.id?t:e):[...o,t]),p(void 0)},children:[(0,Z.jsx)(c,{id:`material-attachment-text`,label:`文本或链接`,children:(0,Z.jsx)(`textarea`,{autoFocus:!0,rows:8,value:f.text,onChange:e=>p({...f,text:e.target.value}),placeholder:`粘贴文本或网页链接`})}),(0,Z.jsx)(`div`,{className:`actions`,children:(0,Z.jsx)(`button`,{type:`submit`,className:`primary`,disabled:!f.text.trim(),children:f.id?`保存`:`添加`})})]})})]})}var pe=v([`overview`,`handoff`]),me=F({title:x().trim().min(1),summary:x().trim().min(1)}).strict(),he=F({markdown:x().trim().min(1)}).strict(),ge=me.extend({sourceRevision:A,sourceHash:P,generatedAt:x(),stale:N()}),_e=F({kind:pe,status:v([`absent`,`queued`,`running`,`succeeded`,`failed`]),available:N(),currentRevision:A,sourceRevision:A.nullable(),stale:N(),result:C([me,he]).nullable(),generatedAt:x().nullable(),error:x().nullable()}),ve=v([`claude-code`,`codex`,`cursor`,`pi`,`dsh`]),ye=F({formatVersion:y(1),adapterVersion:y(1),agent:ve,nativeId:x().min(1).max(512),cwd:x().min(1).max(4096),messages:j(F({id:x().min(1).max(1024),role:v([`user`,`assistant`]),text:x().min(1),source:x().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:E(),sessionKey:P,parentRevision:A,blob:e}).strict(),F({revision:A,hash:P.nullable(),cleared:N()});var be=F({owner:M,sessionKey:P,agent:ve,nativeId:x(),cwd:x(),title:x(),revision:A,updatedAt:x(),messageCount:O().int().nonnegative(),blob:e,overview:ge.optional()}),xe=F({sessions:j(be),nextCursor:A.nullable()}),Se=F({totalSessions:O().int().nonnegative(),totalMessages:O().int().nonnegative(),memberCount:O().int().nonnegative(),updatedAt:x().nullable()});F({owner:M.optional(),sessionKey:P.optional()}).strict().refine(e=>!e.sessionKey||!!e.owner,`A session scope requires an owner.`);var Ce=F({matches:j(F({owner:M,sessionKey:P,revision:A,messageId:x(),source:v([`message`,`handoff`]).default(`message`),role:v([`user`,`assistant`]),snippet:x(),title:x()})),nextCursor:A.nullable()}),we=F({owner:M,key:P,revision:A.refine(e=>e>0).optional(),messageId:x().min(1).optional(),source:v([`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,K.useState)(()=>new Set(n?.key?[n.owner]:[])),[c,u]=(0,K.useState)(e[0]?.id??``);return(0,Z.jsx)(`div`,{role:a===1?`tree`:`group`,"aria-label":`成员对话`,"data-testid":`session-tree`,onKeyDown:a===1?H:void 0,children:[...e].sort((e,t)=>ne(e.id,t.id)).map(e=>(0,Z.jsxs)(`div`,{role:`none`,children:[(0,Z.jsxs)(T,{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:()=>u(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)(l,{name:`chevron`,size:`small`})}),children:[(0,Z.jsx)(l,{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:u},`${e.id}/${t}`)]},e.id))})}function De({level:e,owner:t,selected:n,onSession:i,focused:o,onFocus:c}){let{request:u,projectId:d}=L(),f=(0,K.useCallback)(e=>u(`sessions?${new URLSearchParams({owner:t,limit:`50`,order:`updated`})}`,xe,{signal:e}),[t,u]),m=r(f,15e3,p(d,`session-tree`,t)),[h,_]=(0,K.useState)(),[v,y]=(0,K.useState)(!1),[b,x]=(0,K.useState)(``),S=(0,K.useRef)(null);(0,K.useEffect)(()=>()=>S.current?.abort(),[]);let C=h?h.nextCursor:m.data?.nextCursor;return(0,Z.jsxs)(`div`,{role:`group`,"aria-busy":m.loading||v,children:[(0,Z.jsx)(s,{error:!0,children:m.error||b}),m.error&&(0,Z.jsx)(`button`,{onClick:()=>void m.reload(),children:`重试`}),m.loading&&!m.data&&(0,Z.jsx)(`span`,{className:`tree-status`,role:`status`,children:`正在加载…`}),[...new Map([...h?.sessions??[],...m.data?.sessions??[]].map(e=>[e.sessionKey,e])).values()].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt)||e.sessionKey.localeCompare(t.sessionKey)).map(r=>(0,Z.jsxs)(T,{type:`button`,role:`treeitem`,"aria-level":e,"aria-selected":n?.owner===t&&n.key===r.sessionKey,className:`tree-item`,style:{"--tree-level":e},tabIndex:o===`${t}/${r.sessionKey}`?0:-1,"data-testid":`session-row`,"data-owner-id":t,"data-session-key":r.sessionKey,title:g(r.title||r.nativeId),onFocus:()=>c(`${t}/${r.sessionKey}`),onClick:()=>i({owner:t,key:r.sessionKey,title:r.title||r.nativeId}),leading:(0,Z.jsx)(`span`,{className:`tree-chevron`}),children:[(0,Z.jsx)(l,{name:`sessions`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:g(r.title||r.nativeId)})]},r.sessionKey)),C!=null&&(0,Z.jsx)(`button`,{className:`tree-action`,"data-testid":`session-tree-more`,disabled:v,onClick:async()=>{y(!0),x(``);let e=new AbortController;S.current=e;try{let n=await u(`sessions?${new URLSearchParams({owner:t,after:String(C),limit:`50`,order:`updated`})}`,xe,{signal:e.signal});_(e=>({sessions:[...e?.sessions??[],...n.sessions],nextCursor:n.nextCursor}))}catch(t){e.signal.aborted||x(a(t))}finally{e.signal.aborted||y(!1)}},children:`加载更多`})]})}function Oe({info:e,targeted:t=!1,highlight:n=``}){let[r,i]=(0,K.useState)(t),a=(0,K.useRef)(null);return(0,K.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:n,highlight:i}){let{request:o}=L(),c=`sessions/${encodeURIComponent(e.owner)}/${e.sessionKey}`,l=(0,K.useCallback)(e=>o(`${c}/analysis/handoff${n===void 0?``:`?revision=${n}`}`,_e,{signal:e}),[o,c,n]),u=r(l,5e3),d=m(),[f,p]=(0,K.useState)(!1),[h,g]=(0,K.useState)(``),_=u.data,v=f||_?.status===`queued`||_?.status===`running`,y=_?.result&&`markdown`in _.result?_.result.markdown:void 0;return(0,Z.jsxs)(`div`,{className:`stack`,"data-testid":`session-handoff`,children:[(0,Z.jsx)(s,{error:!0,children:h||u.error}),u.loading&&!_&&(0,Z.jsx)(`small`,{role:`status`,children:`正在加载…`}),_&&(0,Z.jsxs)(`div`,{className:`inline-actions`,children:[_.status===`failed`&&n===void 0&&(0,Z.jsx)(`button`,{"data-testid":`session-handoff-generate`,disabled:v||!_.available,onClick:async()=>{p(!0),g(``);try{await o(`${c}/handoff`,_e,{method:`POST`,signal:d}),await u.reload()}catch(e){d.aborted||g(a(e))}finally{d.aborted||p(!1)}},children:v?`正在整理…`:`重试`}),!_.available&&(0,Z.jsx)(`small`,{children:`请先配置项目模型接入点`}),_.status===`failed`&&(0,Z.jsx)(`small`,{children:`整理未完成,可重试`}),_.available&&_.status!==`failed`&&(!y||_.stale||v)&&(0,Z.jsx)(`small`,{role:`status`,children:_.status===`running`||f?`正在整理…`:y?`对话已有新内容,等待自动更新…`:`等待自动整理…`}),_.currentRevision!==e.revision&&(0,Z.jsx)(`small`,{children:`交接说明使用最新对话;当前阅读的是历史原文`})]}),y&&(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`small`,{children:[`基于版本 `,_.sourceRevision,` · `,(0,Z.jsx)(t,{value:_.generatedAt})]}),(0,Z.jsx)(`div`,{className:`markdown`,"data-testid":`session-handoff-body`,children:(0,Z.jsx)(B,{highlight:i,children:y})})]})]})}function Ae({members:e,active:t,onActivate:n,children:i}){let{request:a,projectId:o,api:c}=L(),l=(0,K.useCallback)(async e=>{let[t,n]=await Promise.all([a(`sessions/stats`,Se,{signal:e}),c.members(e)]);return{...t,members:n.members}},[a,c]),f=r(l,!0,p(o,`session-stats`)),[m,h]=(0,K.useState)(``),[_,v]=(0,K.useState)(``),[y,x]=(0,K.useState)(0),[S]=(0,K.useState)(()=>Te(location.search)),[C,w]=(0,K.useState)(S.target),[T,E]=(0,K.useState)(S.target),[D,O]=(0,K.useState)(S.error??``),[k,A]=(0,K.useState)(``),j=(0,K.useRef)(null),M=C?.key?C.title?`搜索对话:${g(C.title)}`:`搜索当前对话`:C?`搜索:${C.owner} 的对话内容`:``,N=()=>{w(void 0),A(``),P(),j.current?.focus()};function P(){if(!T?.messageId)return;let{messageId:e,...t}=T;E(t),history.replaceState(null,``,I(U(o,t.owner,t.key,t)))}let F=(0,K.useCallback)(e=>{w(t=>t?.owner===e.owner&&t.key===e.sessionKey&&t.title!==e.title?{...t,title:e.title}:t)},[]);(0,K.useEffect)(()=>{let e=()=>{if(!te().endsWith(`/sessions`))return;let e=Te(location.search);E(e.target),w(e.target),O(e.error??``),v(``),h(``),A(``)};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]);let R=(e,t=``)=>{n(),E(e),w(e),v(``),A(t),O(``),history.replaceState(null,``,I(U(o,e.owner,e.key,e)))},z=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(s,{error:!0,children:f.error}),(0,Z.jsx)(Ee,{members:(f.data?.members??e).filter(e=>e.hasSessions),refresh:y,selected:t?C:void 0,level:2,onOwner:e=>{n(),w({owner:e}),E(void 0),v(``),A(``),O(``),history.replaceState(null,``,I(`/projects/${encodeURIComponent(o)}/sessions`))},onSession:R})]}),B=(0,Z.jsxs)(`section`,{className:`session-reader`,"aria-label":`对话内容与搜索`,children:[(0,Z.jsx)(b,{title:d.sessions,icon:`sessions`,count:(0,Z.jsx)(`span`,{"data-testid":`session-total`,children:f.data?.totalSessions??`—`}),children:(0,Z.jsx)(u,{icon:`refresh`,label:`刷新${d.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)(s,{error:!0,children:D}):_?(0,Z.jsx)(je,{query:_,refresh:y,scope:{...C?{owner:C.owner}:{},...C?.key?{sessionKey:C.key}:{}},onSelect:e=>R(e,_)},`${_}/${C?.owner??``}/${C?.key??``}`):T?(0,Z.jsx)(Me,{selection:T,highlight:k,onLoaded:F,onLatest:()=>R({owner:T.owner,key:T.key})},`${T.owner}/${T.key}/${T.revision}/${T.source}/${y}`):(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(),v(m.trim()),A(``),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":`清除范围:${M}`,onClick:N,children:[(0,Z.jsx)(`span`,{className:`scope-label`,children:M}),(0,Z.jsx)(`span`,{"aria-hidden":`true`,children:`×`})]}),(0,Z.jsxs)(`div`,{className:`session-search-input-row`,children:[(0,Z.jsx)(`input`,{ref:j,"aria-label":`搜索对话`,"data-testid":`session-query`,value:m,maxLength:500,placeholder:`搜索会话库内容`,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Backspace`&&!m&&C&&(e.preventDefault(),N())}}),(_||m||k)&&(0,Z.jsx)(u,{icon:`close`,label:`清空搜索`,"data-testid":`session-search-clear`,onClick:()=>{h(``),v(``),A(``),P(),j.current?.focus()}}),(0,Z.jsx)(u,{icon:`search`,type:`submit`,label:`搜索`,"data-testid":`session-search`,disabled:!m.trim()})]})]})]});return i({hasSelection:!!C,tree:z,reader:B,href:T?U(o,T.owner,T.key,T):`/projects/${o}/sessions`})}function je({query:e,refresh:t,scope:n,onSelect:i}){let{request:a}=L(),[o,c]=(0,K.useState)(0),l=(0,K.useCallback)(t=>a(`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}),[a,e,o,t,n.owner,n.sessionKey]),u=r(l);return(0,Z.jsxs)(`section`,{className:`session-results stack`,"aria-label":`搜索结果`,"aria-busy":u.loading,children:[(0,Z.jsx)(s,{error:!0,children:u.error}),u.error&&(0,Z.jsx)(`button`,{onClick:()=>void u.reload(),children:`重试`}),u.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`正在搜索…`}),!u.loading&&u.data?.matches.map(t=>(0,Z.jsxs)(`button`,{className:`session-item`,"data-testid":`session-match`,"data-message-id":t.messageId,onClick:()=>i({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:g(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)(R,{value:z(t.snippet,e),query:e})})]},`${t.owner}:${t.sessionKey}:${t.revision}:${t.source}:${t.messageId}`)),!u.loading&&u.data?.matches.length===0&&(0,Z.jsx)(`p`,{className:`empty`,children:`没有找到匹配的对话`}),u.data?.nextCursor!=null&&(0,Z.jsx)(`button`,{"data-testid":`sessions-next`,disabled:u.loading,onClick:()=>c(u.data.nextCursor),children:`下一页`}),o>0&&(0,Z.jsx)(`button`,{disabled:u.loading,onClick:()=>c(0),children:`返回第一页`})]})}function Me({selection:e,highlight:t,onLoaded:n,onLatest:i}){let{request:a}=L(),c=(0,K.useCallback)(async t=>{try{return await a(`sessions/${encodeURIComponent(e.owner)}/${e.key}${e.revision===void 0?``:`?revision=${e.revision}`}`,be,{signal:t})}catch(e){throw e instanceof o&&e.code===`SESSION_NOT_FOUND`?Error(`找不到这条对话或引用的版本,原链接可能已失效。`):e}},[a,e.owner,e.key,e.revision]),l=r(c,5e3);return(0,K.useEffect)(()=>{l.data&&n(l.data)},[l.data,n]),(0,Z.jsxs)(`section`,{className:`session-conversation stack`,"data-testid":`session-detail`,children:[(0,Z.jsx)(s,{error:!0,children:l.error}),l.error&&(0,Z.jsx)(`button`,{onClick:()=>void l.reload(),children:`重试`}),l.loading&&!l.data&&(0,Z.jsx)(`p`,{role:`status`,children:`正在读取对话…`}),l.data&&(0,Z.jsx)(Ne,{info:l.data,messageId:e.messageId,handoff:e.source===`handoff`,highlight:t,pinned:e.revision!==void 0,onLatest:i},l.data.blob.sha256)]})}function Ne({info:e,messageId:n,handoff:i,highlight:a,pinned:o,onLatest:c}){let{readTextBlob:l,projectId:u}=L(),d=(0,K.useCallback)(async t=>ye.parse(JSON.parse(await l(e.blob,t))),[e.blob.sha256,e.blob.size]),f=r(d),p=(0,K.useRef)(null);return(0,K.useEffect)(()=>{f.data&&n&&p.current?.scrollIntoView({block:`center`})},[f.data,n]),(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`header`,{className:`conversation-header`,children:[(0,Z.jsx)(`h2`,{className:`session-title`,children:g(e.title||e.nativeId)}),(0,Z.jsxs)(`p`,{children:[e.owner,` · `,e.agent,` · `,e.messageCount,` 条消息`]}),(0,Z.jsxs)(`small`,{children:[(0,Z.jsx)(t,{value:e.updatedAt}),o&&(0,Z.jsxs)(Z.Fragment,{children:[` `,`· 引用版本 `,e.revision,` ·`,` `,(0,Z.jsx)(`a`,{href:I(U(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:i,highlight:i?a:``}),(0,Z.jsx)(s,{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:[n&&!f.data.messages.some(e=>e.id===n)&&(0,Z.jsx)(s,{children:`该版本中找不到引用的消息,已打开对话原文。`}),(0,Z.jsx)(`div`,{className:`session-messages`,children:f.data.messages.map(e=>(0,Z.jsx)(V,{mine:e.role===`user`,author:e.role===`user`?`用户`:`助手`,className:`session-message ${e.role} ${e.id===n?`matched`:``}`,"data-testid":`session-message`,"data-message-id":e.id,ref:e.id===n?p:void 0,children:(0,Z.jsx)(`div`,{className:`markdown`,children:(0,Z.jsx)(B,{highlight:a,children:e.text})})},e.id))})]})]})}var $=x().trim().min(1).max(120).refine(e=>!/[\r\n]/.test(e),`请使用一句简短的项目记忆。`),Pe=F({id:E(),text:$,state:v([`draft`,`kept`]),revision:O().int().positive(),createdAt:x(),updatedAt:x()}),Fe=F({cards:j(Pe)});F({id:E(),text:$}).strict(),F({expectedRevision:O().int().positive(),text:$.optional(),action:v([`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,K.useCallback)(t=>e(`memory`,Fe,{signal:t}),[e]),i=r(n,5e3,p(t,`memory`)),[a,o]=(0,K.useState)(null),[c,l]=(0,K.useState)({}),d=(0,K.useRef)(null),m=[...i.data?.cards??[]];for(let e of Object.values(c))m.some(t=>t.id===e.id)||m.push(e);if(i.data&&!d.current&&(d.current=[...m].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 m)e.has(t.id)||(e.set(t.id,d.current.length),d.current.push(t.id));m.sort((t,n)=>e.get(t.id)-e.get(n.id))}return(0,Z.jsxs)(`section`,{className:`memory-page`,children:[(0,Z.jsx)(f,{title:`记忆`,children:(0,Z.jsx)(u,{icon:`plus`,label:`新增记忆`,disabled:!!a,onClick:()=>o(h())})}),(0,Z.jsx)(s,{error:!0,children:i.error}),!i.data&&i.loading&&(0,Z.jsx)(`p`,{role:`status`,children:`加载中…`}),(0,Z.jsxs)(`div`,{className:`memory-cards`,children:[a&&(0,Z.jsx)(Le,{id:a,onDone:()=>o(null),reload:i.reload},a),m.map(e=>(0,Z.jsx)(Le,{id:e.id,card:e,reload:i.reload,onEditing:t=>l(n=>{let r={...n};return t?r[e.id]=e:delete r[e.id],r})},e.id))]}),i.data&&m.length===0&&!a&&(0,Z.jsx)(`p`,{className:`memory-empty`,children:`暂无记忆`})]})}function Le({id:e,card:t,reload:n,onDone:r,onEditing:i}){let{request:o}=L(),[c,d]=(0,K.useState)(!t),[f,p]=(0,K.useState)(t?.text??``),[m,h]=(0,K.useState)(t?.revision),[g,_]=(0,K.useState)(!1),[v,y]=(0,K.useState)(``),b=(0,K.useRef)(!1),x=(0,K.useRef)(!1);function S(){x.current=!1,i?.(!0),p(t?.text??``),h(t?.revision),y(``),d(!0)}function C(){x.current=!0,d(!1),y(``),i?.(!1),r?.()}async function w(s){if(!b.current){if(!s&&t&&f===t.text)d(!1),i?.(!1);else if((!s||s===`keep`)&&!$.safeParse(c?f:t?.text).success)y(`请填写一句记忆,最多 120 个字符。`);else{b.current=!0,_(!0),y(``);try{t?await o(`memory/${e}`,F({saved:N()}),{method:`PATCH`,body:{expectedRevision:c?m:t.revision,...s?{action:s}:{},...c&&s!==`discard`&&s!==`delete`?{text:f}:{}}}):await o(`memory`,Pe,{method:`POST`,body:{id:e,text:f}}),d(!1),await n(),i?.(!1),r?.()}catch(e){y(a(e)),await n()}finally{b.current=!1,_(!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)(l,{name:t?.state===`kept`?`check`:`question`})}),(0,Z.jsxs)(`div`,{className:`memory-content`,children:[c?(0,Z.jsx)(`textarea`,{autoFocus:!0,"aria-label":`记忆内容`,value:f,maxLength:120,rows:2,disabled:g,onChange:e=>p(e.target.value.replace(/[\r\n]+/g,` `)),onBlur:e=>{x.current?x.current=!1:e.relatedTarget instanceof Element&&e.relatedTarget.closest(`.memory-actions`)||v||w()},onKeyDown:e=>{e.nativeEvent.isComposing||(e.key===`Escape`&&(e.preventDefault(),C()),e.key===`Enter`&&(e.preventDefault(),w()))}}):(0,Z.jsx)(`button`,{type:`button`,className:`memory-text`,"aria-label":`编辑记忆:${t?.text??``}`,onClick:S,children:t?.text}),(0,Z.jsx)(s,{error:!0,children:v})]}),(0,Z.jsxs)(`div`,{className:`memory-actions`,onMouseDown:e=>{c&&e.preventDefault()},children:[(!t||t.state===`draft`)&&(0,Z.jsx)(u,{icon:`check`,label:t?`保留记忆`:`保存记忆`,disabled:g,onClick:()=>void w(t?`keep`:void 0)}),c&&t?.state===`kept`&&(0,Z.jsx)(u,{icon:`check`,label:`保存记忆`,disabled:g,onClick:()=>void w()}),(0,Z.jsx)(u,{icon:`close`,label:t?t.state===`draft`?`舍弃记忆`:`删除记忆`:`取消新增`,disabled:g,onClick:()=>{t?w(t.state===`draft`?`discard`:`delete`):C()}})]})]})}function Re({section:e,members:t,navigate:n}){let{projectId:r}=L(),[i,a]=(0,K.useState)(e===`sessions`);(0,K.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)(S,{reading:!0,className:`resource-library`,"data-testid":`materials-page`,label:`资料目录`,navigation:(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(b,{title:`资料`,icon:`materials`,children:r.actions}),(0,Z.jsxs)(`div`,{role:`tree`,"aria-label":`项目资料`,onKeyDown:H,style:{"--tree-level":1},children:[(0,Z.jsxs)(T,{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)(l,{name:`files`}),(0,Z.jsx)(`span`,{className:`tree-name`,children:`记忆`})]}),(0,Z.jsxs)(T,{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)(l,{name:`chevron`,size:`small`})}),onClick:()=>{a(!i),e!==`sessions`&&n(t.href)},children:[(0,Z.jsx)(l,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as e,H as t,J as n,L as r,N as i,U as a,_t as o,c as s,h as c,l,s as u,u as d,y as f}from"./index-DD447Vev.js";var p=o(),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:u,path:``,level:1,members:e.filter(e=>e.hasFiles),context:{...t,focused:n,onFocus:r}})})}function x({owner:e,path:t,level:n,context:r}){let a=r.expanded.has(v(e,t)),o=`folder:${v(e,t)}`;return(0,g.jsxs)(`div`,{role:`none`,children:[(0,g.jsxs)(c,{type:`button`,role:`treeitem`,className:`tree-item tree-folder`,style:y(n),"aria-label":t||e,"aria-level":n,"aria-expanded":a,"aria-selected":r.selected?.kind===`directory`&&r.selected.owner===e&&r.selected.path===t,tabIndex:r.focused===o?0:-1,"data-testid":`directory-row`,"data-owner-id":e,"data-directory-path":t,onFocus:()=>r.onFocus(o),onClick:()=>r.onToggle(e,t),leading:(0,g.jsx)(`span`,{className:`tree-chevron ${a?`expanded`:``}`,children:(0,g.jsx)(i,{name:`chevron`,size:`small`})}),children:[(0,g.jsx)(i,{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:r})]})}function S({owner:e,path:o,level:u,context:m,members:_=[]}){let{api:b,projectId:S}=f(),C=(0,p.useCallback)(t=>b.tree(e,o,void 0,``,t),[e,o]),w=t(C,!1,a(S,`file-tree`,e,o)),[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 n=await b.tree(e,o,w.data.revision,N,t.signal);t.signal.aborted||E({...n,entries:[...M?.entries??[],...n.entries]})}catch(e){t.signal.aborted||A(n(e))}finally{t.signal.aborted||O(!1)}}let F=[...(w.data?.entries??[]).filter(e=>!l(e.path)),...(M?.entries??[]).filter(e=>!l(e.path))],I=m.revealed;if(I?.owner===e&&!l(I.path)&&(!o||I.path.startsWith(o+`/`))){let e=o?I.path.slice(o.length+1):I.path,t=e.indexOf(`/`),n=t<0?I.path:[o,e.slice(0,t)].filter(Boolean).join(`/`);F.some(e=>e.path===n)||F.push(t<0?{...I.file,kind:`file`}:{kind:`directory`,path:n})}let L=[...F.filter(t=>e!==`_project`||!s(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(d(e)?`teamcontext`:e,o),"aria-busy":w.loading||D,children:[w.loading&&(0,g.jsx)(`p`,{className:`tree-status`,role:`status`,children:`正在加载…`}),(0,g.jsx)(r,{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:u,context:m},v(t.owner,t.path)):(0,g.jsxs)(c,{type:`button`,role:`treeitem`,className:`tree-item`,style:y(u),"aria-label":t.path,"aria-level":u,"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)(i,{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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{et as e}from"./index-DD447Vev.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};
|