@teammy/server 0.2.7 → 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.
- package/dist/main.js +1943 -1604
- package/dist/native-pi-entry.js +4 -2
- package/dist/runtime/README.md +2 -2
- package/dist/runtime/shared/tools.json +1 -1
- package/dist/runtime/workflows/session-handoff/config.json +1 -1
- package/dist/runtime/workflows/session-handoff/prompt.md +1 -1
- package/dist/web/assets/Assistant-CYSa4zNi.js +1 -0
- package/dist/web/assets/Computers-4L48XuFg.js +4 -0
- package/dist/web/assets/Computers-_ugR447I.css +1 -0
- package/dist/web/assets/{Conversation-DCiZ74nB.js → Conversation-BBWm5w-C.js} +1 -1
- package/dist/web/assets/Dashboard-Bdh00JcC.css +1 -0
- package/dist/web/assets/Dashboard-Ck2NsAbX.js +1 -0
- package/dist/web/assets/Files-CjNjoKS3.js +1 -0
- package/dist/web/assets/{Help-Bn-Jg_iu.js → Help-DwUoT8ZM.js} +137 -55
- package/dist/web/assets/{HtmlPreview-BJx9pmVO.js → HtmlPreview-B6aQIaMB.js} +1 -1
- package/dist/web/assets/{Markdown-B_-v2uex.js → Markdown-DorC2YjE.js} +4 -4
- package/dist/web/assets/MessageComposer-DQBDG5yF.js +1 -0
- package/dist/web/assets/ResourceLibrary-104NuVRn.js +6 -0
- package/dist/web/assets/{ResourceLibrary-COmSSC8U.css → ResourceLibrary-BB5EdMby.css} +1 -1
- package/dist/web/assets/WorkspaceTree-B4FMRlCw.js +1 -0
- package/dist/web/assets/{file-links-B7mOk5cJ.js → file-links-DnngiTbC.js} +1 -1
- package/dist/web/assets/index-DiR0ePCJ.js +66 -0
- package/dist/web/downloads/teammy-skill.zip +0 -0
- package/dist/web/index.html +1 -1
- package/package.json +1 -1
- package/dist/web/assets/Assistant-umYSc37u.js +0 -1
- package/dist/web/assets/Computers-Dc45R6Gl.css +0 -1
- package/dist/web/assets/Computers-DuN7_voW.js +0 -3
- package/dist/web/assets/Dashboard-DIunax0h.css +0 -1
- package/dist/web/assets/Dashboard-DKK-o9Pg.js +0 -1
- package/dist/web/assets/Files-D4qQlYub.js +0 -1
- package/dist/web/assets/MessageComposer-BiYDdtAk.js +0 -1
- package/dist/web/assets/ResourceLibrary-BWUmPV--.js +0 -6
- package/dist/web/assets/WorkspaceTree-DVZ1Gzer.js +0 -1
- package/dist/web/assets/index-DRdoKPDu.js +0 -66
package/dist/native-pi-entry.js
CHANGED
|
@@ -52,7 +52,9 @@ var TaskQuerySchema = z.object({
|
|
|
52
52
|
id: z.uuid().optional(),
|
|
53
53
|
source: z.string().optional(),
|
|
54
54
|
query: z.string().optional(),
|
|
55
|
-
visibility: z.enum(["active", "archived", "all"]).optional()
|
|
55
|
+
visibility: z.enum(["active", "archived", "all"]).optional(),
|
|
56
|
+
offset: z.number().int().nonnegative().default(0),
|
|
57
|
+
limit: z.number().int().positive().default(40)
|
|
56
58
|
}).strict();
|
|
57
59
|
|
|
58
60
|
// apps/server/ai/models.ts
|
|
@@ -368,7 +370,7 @@ async function run(config) {
|
|
|
368
370
|
const query = {
|
|
369
371
|
name: "query_tasks",
|
|
370
372
|
...runtime.toolText.query_tasks,
|
|
371
|
-
parameters: Type3.Unsafe(z4.toJSONSchema(TaskQuerySchema)),
|
|
373
|
+
parameters: Type3.Unsafe(z4.toJSONSchema(TaskQuerySchema, { io: "input" })),
|
|
372
374
|
async execute(_id, params) {
|
|
373
375
|
const value = await rpc({ method: "query_tasks", input: TaskQuerySchema.parse(params) });
|
|
374
376
|
return { content: [{ type: "text", text: JSON.stringify(value) }], details: {} };
|
package/dist/runtime/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
|
|
11
11
|
会话整理使用独立的 `session-overview` 和 `session-handoff` 资源,不加载文件探索的共享 system/tool 提示词。前者自动生成标题和短摘要,后者自动生成详细交接说明;二者分别调用 SDK。配置仅包含版本、合并等待、单次请求时限与推理级别,首次执行冻结资源,自动重试沿用。详见 [会话整理](../../../../docs/session-analysis.md)。
|
|
12
12
|
|
|
13
|
-
`task-bootstrap`
|
|
13
|
+
`task-bootstrap` v13 同时负责首次整理和后续维护,`directory-analysis` v3 复用原生沙箱。整个 Pi 进程在 Linux Bubblewrap 沙箱中运行,挂载只读成员工作区和可选历史基线。原生 read/bash/grep/find/ls 不由此目录改写描述,只有 query_tasks 是 Teammy 自定义工具,用于查询已有任务。业务提示词追加到 Pi 原生系统提示;最终输出 upsert / archive 与任务级 needsConfirmation,不生成分析级 uncertainties。旧冻结作业保留快照工具协议。详见 [任务维护设计](../../../../docs/task-agent-maintenance-v1.md)。
|
|
14
14
|
|
|
15
15
|
`thinkingLevel` 默认 off;设为其他级别时通过 Pi 的通用推理参数映射传给适配器,接入点需支持对应推理能力。上下文和输出限额由网关处理,Teammy 不配置或发送这些额度。
|
|
16
16
|
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
- `query`:标题、目标、进展或来源路径的子串,不区分大小写。
|
|
30
30
|
- `visibility`:`active`、`archived` 或 `all`。默认 `active`;指定 `id` 时默认 `all`。`active` 表示未归档,也包含已完成任务。
|
|
31
31
|
|
|
32
|
-
返回 `{ items, total, omitted,
|
|
32
|
+
返回 `{ items, total, omitted, nextOffset }`。`total` 为匹配总数,`items` 默认每页 40 项,可用 offset、limit 和返回的 nextOffset 继续读取;nextOffset 为 null 表示已读完。每项包含 `taskId`、`revision`、`lastEdit`、`title`、`goal`、`status`、`progress`、`needsConfirmation`、`sources`、`active`;来源包含 `path`、`sha256`、`revision` 与 `syncedAt`。字段正文保留完整内容,直接包含用户修改;lastEdit 记录最近一次人工或委托修改的时间及操作者(旧数据可未知)。后续分析依据新证据继续维护,没有永久覆盖字段。
|
|
33
33
|
|
|
34
34
|
当前数据范围是**作业创建时冻结的单成员任务**,不是实时的全项目查询;参数不支持项目或成员切换。调用范围由宿主提供的 `TaskContext` 和成员身份决定,工具自身不访问数据库,也没有同名 HTTP 路由。
|
|
35
35
|
|
|
@@ -17,6 +17,6 @@
|
|
|
17
17
|
},
|
|
18
18
|
"query_tasks": {
|
|
19
19
|
"label": "查询当前成员任务",
|
|
20
|
-
"description": "Read-only query of tasks belonging ONLY to the member assigned to this maintenance run; never queries other members or changes ownership. Filter by id, source (file or directory prefix relative to teamcontext), or query (title/goal/progress/source substring). visibility=active (default), archived or all; an exact id defaults to all. Returns taskId (use in the final upsert/archive result), current task fields, revision, lastEdit (latest human/delegated edit, nullable time and actor), sources and active flag. Continue from these current values, including user edits, using new evidence; do not reconstruct a separate automatic version from old files.
|
|
20
|
+
"description": "Read-only query of tasks belonging ONLY to the member assigned to this maintenance run; never queries other members or changes ownership. Filter by id, source (file or directory prefix relative to teamcontext), or query (title/goal/progress/source substring). visibility=active (default), archived or all; an exact id defaults to all. Returns taskId (use in the final upsert/archive result), current task fields, revision, lastEdit (latest human/delegated edit, nullable time and actor), sources and active flag. Continue from these current values, including user edits, using new evidence; do not reconstruct a separate automatic version from old files. Results are paginated: offset defaults to 0 and limit to 40. Pass nextOffset as offset to continue; null means the final page. Field text remains complete."
|
|
21
21
|
}
|
|
22
22
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Et as t,G as n,H as r,Q as i,Tt as a,U as o,V as s,W as c,X as l,Z as u,_t as d,a as ee,c as f,et as te,gt as ne,ht as p,i as m,mt as h,nt as g,o as re,r as ie,rt as _,s as ae,v,vt as y,x as oe,xt as se,yt as b}from"./index-DiR0ePCJ.js";import{t as ce}from"./Markdown-DorC2YjE.js";import{a as le,i as ue,n as de,r as fe,t as pe}from"./Conversation-BBWm5w-C.js";import{t as me}from"./MessageComposer-DQBDG5yF.js";var x=a(),S=e(),he=y({topics:h(y({id:b(),title:b(),summary:b(),author:b(),replies:d(),unread:p(),createdAt:b(),updatedAt:b(),delivery:y({available:p(),connected:p(),state:b(),error:b().nullable()})}))}),ge=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}),C=e=>e.replace(/[#*_`>]/g,``).replace(/\s+/g,` `).trim();function w({me:e,mode:a=`messages`}){let{projectId:d,request:h}=oe(),w=i(),ve=u(d,e,`${a}-selection`),T=u(d,e,`${a}-drafts`),ye=(0,x.useCallback)(e=>h(`agents/outbox`,ae,{signal:e}),[h]),E=l(ye,3e3,u(d,e,`outbox`)),be=(0,x.useCallback)(async e=>a===`messages`?h(`agents/chats`,ie,{signal:e}):{chats:(await h(`channels/topics`,he,{signal:e})).topics.map(e=>({...e,kind:`matter`,state:null}))},[h,a]),D=l(be,3e3,u(d,e,a,`chats`)),[O,xe]=(0,x.useState)(()=>{let e=new URLSearchParams(location.search),t=e.get(`chat`);return t?`chat:${t}`:e.get(`message`)??w?.get(ve)??``}),k=O.startsWith(`chat:`)?O.slice(5):``,A=!O||!!k,[j,M]=(0,x.useState)(()=>w?.get(u(d,e,`chat`,k))),N=j?.id===k?j:w?.get(u(d,e,`chat`,k)),P=D.data?.chats.find(e=>e.id===k),F=P&&`delivery`in P?P.delivery:void 0,[Se,I]=(0,x.useState)(),[L,R]=(0,x.useState)(()=>w?.get(T)??{}),Ce=L[O]??``,we=e=>R(t=>({...t,[O]:e})),[z,B]=(0,x.useState)(!1),[V,Te]=(0,x.useState)(!1),[Ee,De]=(0,x.useState)(!1),[Oe,H]=(0,x.useState)(!1),[U,ke]=(0,x.useState)(``),[Ae,je]=(0,x.useState)(``),Me=(0,x.useRef)(_()),[Ne,W]=(0,x.useState)(``),[Pe,G]=(0,x.useState)(``),K=(0,x.useRef)(new Map),Fe=(0,x.useRef)(null),q=(0,x.useRef)(!0),J=(0,x.useRef)(O);J.current=O,(0,x.useEffect)(()=>{j&&w?.set(u(d,e,`chat`,j.id),j)},[w,d,e,j]),(0,x.useEffect)(()=>{w?.set(T,L)},[w,T,L]);function Y(e){J.current=e,xe(e),w?.set(ve,e);let t=new URL(location.href);e.startsWith(`chat:`)?t.searchParams.set(`chat`,e.slice(5)):t.searchParams.delete(`chat`),e&&!e.startsWith(`chat:`)&&e!==`debug`?t.searchParams.set(`message`,e):t.searchParams.delete(`message`),history.replaceState(history.state,``,t)}(0,x.useEffect)(()=>{!O&&D.data?.chats.length&&Y(`chat:${D.data.chats[0].id}`)},[O,D.data]);let X=(E.data?.messages??[]).filter(e=>a===`messages`&&e.box===`debug`).reverse(),Z=E.data?.messages.find(e=>e.id===(O===`debug`?Se:O));(0,x.useEffect)(()=>{O!==`debug`&&Z?.conversationId&&Y(`chat:${Z.conversationId}`)},[O,Z?.conversationId]);let Q=X.filter(e=>!e.readAt).map(e=>e.id).join(`,`);(0,x.useEffect)(()=>{Z&&!Z.readAt&&O!==`debug`&&h(`agents/outbox/${Z.id}/read`,f,{method:`POST`}).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(g(e)))},[Z?.id,Z?.readAt,O,h,E.reload]),(0,x.useEffect)(()=>{O===`debug`&&Q&&Promise.all(Q.split(`,`).map(e=>h(`agents/outbox/${e}/read`,f,{method:`POST`}))).then(()=>{window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}).catch(e=>W(g(e)))},[O,Q,h,E.reload]),(0,x.useEffect)(()=>{if(G(``),!k)return;let n=!0,r=-1,i=!1,o=new AbortController,s=e=>{!n||e.id!==k||e.cursor<r||(r=e.cursor,i=!0,e.redirect?Y(`chat:${e.redirect}`):e.entry===`channel`&&a!==`channels`?location.replace(t(`/projects/${d}/channels?chat=${e.id}`)):(M(e),G(``)))};h(`agents/chats/${k}`,m,{signal:o.signal}).then(s).catch(t=>{n&&!o.signal.aborted&&(t instanceof te&&[401,403,404].includes(t.status)&&(w?.delete(u(d,e,`chat`,k)),M(e=>e?.id===k?void 0:e)),i||G(g(t)))});let c=e=>{let t=Number(e.lastEventId);return!n||!Number.isSafeInteger(t)||t<=r?!1:(r=t,!0)},l=new EventSource(t(`/api/v1/projects/${encodeURIComponent(d)}/agents/chats/${encodeURIComponent(k)}/events`));l.addEventListener(`snapshot`,e=>{if(n)try{s(m.parse(JSON.parse(e.data)))}catch(e){G(g(e))}}),l.onerror=()=>{n&&G(`对话连接中断,正在重新连接…`)},l.addEventListener(`context`,e=>{if(!c(e))return;let t=m.pick({kind:!0,title:!0,status:!0,visibility:!0,participants:!0,pending:!0,hold:!0,redirect:!0}).parse(JSON.parse(e.data));t.redirect?Y(`chat:${t.redirect}`):M(e=>e?.id===k?{...e,...t,cursor:r}:e)}),l.addEventListener(`message`,e=>{if(!c(e))return;let t=ee.parse(JSON.parse(e.data));M(n=>n?.id===k?{...n,readCursor:Math.max(n.readCursor,t.seq),cursor:Math.max(n.cursor,Number(e.lastEventId)||0),messages:[...n.messages.filter(e=>e.id!==t.id),t].sort((e,t)=>e.seq-t.seq)}:n)}),l.addEventListener(`message_removed`,e=>{if(!c(e))return;let{id:t}=y({id:b()}).parse(JSON.parse(e.data));M(e=>e?.id===k?{...e,cursor:r,messages:e.messages.filter(e=>e.id!==t)}:e)}),l.addEventListener(`run`,e=>{if(!c(e))return;let t=re.parse(JSON.parse(e.data));M(n=>n?.id===k?{...n,cursor:Math.max(n.cursor,Number(e.lastEventId)||0),runs:n.runs.some(e=>e.id===t.id)?n.runs:[...n.runs,t]}:n)});for(let e of[`delta`,`reset`,`state`])l.addEventListener(e,t=>{if(!c(t))return;let n=JSON.parse(t.data);M(r=>r?.id===k?{...r,cursor:Math.max(r.cursor,Number(t.lastEventId)||0),messages:r.messages.map(t=>t.runId!==n.id||t.role!==`assistant`?t:{...t,body:e===`delta`?t.body+(n.text??``):e===`reset`?``:n.answer??t.body,state:n.state??t.state}),runs:r.runs.map(t=>t.id===n.id?{...t,answer:e===`delta`?t.answer+(n.text??``):e===`reset`?``:n.answer??t.answer,state:n.state??t.state,error:n.error===void 0?t.error:n.error}:t)}:r)});return()=>{n=!1,o.abort(),l.close()}},[d,k,e,h,w]),(0,x.useEffect)(()=>{if(!N||N.id!==k)return;let e=()=>{document.visibilityState===`visible`&&h(`agents/chats/${k}/read`,y({ok:p()}),{method:`POST`,body:{cursor:N.readCursor}}).then(()=>{D.reload(),window.dispatchEvent(new Event(`teammy:outbox`))}).catch(e=>W(g(e)))},t=setTimeout(e,300);return document.addEventListener(`visibilitychange`,e),()=>{clearTimeout(t),document.removeEventListener(`visibilitychange`,e)}},[k,N?.readCursor,N?.kind,h]),(0,x.useEffect)(()=>{q.current&&Fe.current?.scrollIntoView({block:`end`})},[O,j?.messages,Z?.recipients,X.length]);function Ie(){window.dispatchEvent(new Event(`teammy:outbox`)),E.reload()}async function $(e){if(q.current=!0,Y(e),W(``),I(void 0),e.startsWith(`chat:`)||e===`debug`)return;let t=E.data?.messages.find(t=>t.id===e)?.conversationId;if(t)Y(`chat:${t}`);else try{await h(`agents/outbox/${e}/read`,f,{method:`POST`}),Ie()}catch(e){W(g(e))}}async function Le(){if(!V){Te(!0),W(``);try{let e=await h(`agents/chats`,m,{method:`POST`});M(e),await $(`chat:${e.id}`),D.reload()}catch(e){W(g(e))}finally{Te(!1)}}}async function Re(e){e.preventDefault();let t=Ce.trim();if(!t||z||V)return;B(!0),W(``);let n=K.current.get(O);n&&n.text===t||(n={text:t,id:_()},K.current.set(O,n));try{if(A){let e=n.target??k;if(!e){let r=await h(`agents/chats`,m,{method:`POST`});e=r.id,n.target=e,K.current.set(`chat:${e}`,n),R(n=>({...n,[`chat:${e}`]:t})),J.current===O&&(M(r),Y(`chat:${e}`))}let r=await h(`agents/chats/${e}`,re.extend({conversationId:b().optional()}),{method:`POST`,body:{text:t,requestId:n.id}});r.conversationId&&r.conversationId!==e&&(J.current===O||J.current===`chat:${e}`)&&Y(`chat:${r.conversationId}`),M(t=>t?.id===e?{...t,runs:t.runs.some(e=>e.id===r.id)?t.runs:[...t.runs,r]}:t),D.reload()}else{let e=await h(`agents/outbox/${Z.id}/reply`,y({conversationId:b()}),{method:`POST`,body:{body:t,requestId:n.id}});Ie(),J.current===O&&Y(`chat:${e.conversationId}`),D.reload(),I(void 0)}K.current.delete(O),n.target&&K.current.delete(`chat:${n.target}`),R(e=>({...e,[O]:``,...n.target?{[`chat:${n.target}`]:``}:{}}))}catch(e){W(g(e))}finally{B(!1)}}let ze=a===`channels`?ue:pe,Be=A&&!N?.closed&&(a!==`channels`||!!k)||!!Z&&!Z.archivedAt,Ve=A&&!N&&(!!k||!D.data);return(0,S.jsxs)(fe,{className:a===`channels`?`channel-layout`:``,testId:`assistant-page`,label:A?`Tim对话`:`消息内容`,navigation:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`header`,{className:`assistant-list-heading`,children:[(0,S.jsx)(`h1`,{children:a===`channels`?`频道`:`对话`}),(0,S.jsxs)(`div`,{className:`assistant-list-actions`,children:[(0,S.jsx)(r,{className:`assistant-new-chat`,icon:`clear`,label:`清除未读`,disabled:Ee,onClick:()=>{De(!0),W(``),h(`communication/read`,y({ok:ne(!0)}),{method:`POST`,body:{scope:a}}).then(async()=>{window.dispatchEvent(new Event(`teammy:outbox`)),await Promise.all([D.reload(),E.reload()])}).catch(e=>W(g(e))).finally(()=>De(!1))}}),(0,S.jsx)(r,{className:`assistant-new-chat`,icon:`plus`,label:a===`channels`?`发表话题`:`新建对话`,disabled:V,onClick:()=>a===`channels`?H(!0):void Le(),"data-testid":`assistant-launcher`})]})]}),(0,S.jsxs)(`div`,{className:`assistant-message-scroll`,children:[D.loading&&!D.data&&(0,S.jsx)(`p`,{className:`assistant-list-status`,role:`status`,children:`加载中…`}),D.data?.chats.map(e=>(0,S.jsxs)(`button`,{type:`button`,"data-testid":`assistant-chat-${e.id}`,className:`assistant-message-item assistant-chat-item ${k===e.id?`selected`:``}`,"aria-pressed":k===e.id,onClick:()=>void $(`chat:${e.id}`),children:[(0,S.jsx)(`span`,{className:`assistant-message-dot ${e.unread||a!==`channels`&&(e.state===`running`||e.state===`queued`)?`unread`:``}`}),(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:k===e.id,children:(0,S.jsx)(`strong`,{children:e.title})}),a===`channels`&&`summary`in e&&(0,S.jsx)(`span`,{className:`topic-preview`,children:C(String(e.summary)).slice(0,140)}),(0,S.jsxs)(`time`,{dateTime:e.updatedAt,children:[new Date(e.updatedAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ge(e.updatedAt)]})]})]},e.id)),!!X.length&&(0,S.jsxs)(`button`,{type:`button`,"data-testid":`debug-outbox`,className:`assistant-message-item ${O===`debug`?`selected`:``}`,onClick:()=>void $(`debug`),children:[(0,S.jsx)(`span`,{className:`assistant-message-dot ${Q?`unread`:``}`}),(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:O===`debug`,children:(0,S.jsx)(`strong`,{children:`运行提醒`})}),(0,S.jsx)(`span`,{children:C(X.at(-1).body)})]})]}),E.data?.messages.filter(e=>a===`messages`&&e.box!==`debug`&&!e.conversationId).sort((e,t)=>Number(!!e.archivedAt)-Number(!!t.archivedAt)).map(e=>(0,S.jsxs)(`button`,{type:`button`,"data-testid":`outbox-${e.id}`,className:`assistant-message-item ${e.archivedAt?`archived`:``} ${O===e.id?`selected`:``}`,onClick:()=>void $(e.id),children:[(0,S.jsx)(`span`,{className:`assistant-message-dot ${e.readAt?``:`unread`}`}),(0,S.jsxs)(`span`,{className:`assistant-message-copy`,children:[(0,S.jsx)(v,{selected:O===e.id,children:(0,S.jsx)(`strong`,{children:C(e.body)})}),(0,S.jsxs)(`time`,{dateTime:e.createdAt,children:[new Date(e.createdAt).toLocaleDateString([],{month:`numeric`,day:`numeric`}),` `,ge(e.createdAt)]})]})]},e.id))]}),(0,S.jsx)(n,{error:!0,children:E.error||D.error})]}),children:[Oe&&(0,S.jsxs)(c,{id:`new-topic`,title:`发表话题`,onClose:()=>H(!1),children:[(0,S.jsx)(me,{inset:!0,plain:!0,value:Ae,onChange:je,label:`正文`,placeholder:`开始一个话题…`,sendLabel:`发表话题`,sendDisabled:z||!U.trim(),heading:(0,S.jsx)(`input`,{className:`topic-title`,"aria-label":`标题`,placeholder:`标题`,required:!0,value:U,onChange:e=>ke(e.target.value)}),onSubmit:e=>{e.preventDefault(),B(!0),W(``),h(`channels/topics`,m,{method:`POST`,body:{id:Me.current,title:U,body:Ae}}).then(e=>{M(e),Y(`chat:${e.id}`),H(!1),ke(``),je(``),Me.current=_(),D.reload()}).catch(e=>W(g(e))).finally(()=>B(!1))}}),(0,S.jsx)(n,{error:!0,children:Ne})]}),(0,S.jsx)(de,{title:(0,S.jsx)(`h2`,{children:A?P?.title??N?.title??(k?`无标题`:`Tim`):O===`debug`?`运行提醒`:`项目消息`}),actions:(0,S.jsxs)(S.Fragment,{children:[a!==`channels`&&N?.kind===`matter`&&(0,S.jsxs)(`span`,{className:`assistant-participants`,title:N.participants?.join(`、`),children:[N.visibility===`project`?`项目共享 · `:``,N.participants?.join(`、`)]}),a===`channels`&&F?.available&&(F.state===`web`||F.state===`cancelled`||!F.connected)&&(0,S.jsx)(r,{icon:`send`,label:`发布到企业微信频道`,disabled:z,onClick:()=>{B(!0),h(`channels/topics/${k}/publish`,se(),{method:`POST`}).then(()=>D.reload()).catch(e=>W(g(e))).finally(()=>B(!1))}})]})}),a===`channels`&&(0,S.jsx)(n,{error:!0,children:F?.error}),a!==`channels`&&N?.kind===`matter`&&(N.hold||N.pending||N.status===`completed`)&&(0,S.jsx)(`div`,{className:`assistant-matter-state`,role:`status`,children:N.hold?`${N.hold.scope===`all`?`已暂停`:`暂缓修改`} · ${N.hold.reason}`:N.pending?`待确认 · ${N.pending.members.join(`、`)}:${N.pending.question}`:`已完成`}),(0,S.jsxs)(le,{"data-testid":`assistant-transcript`,onScroll:e=>{let t=e.currentTarget;q.current=t.scrollHeight-t.scrollTop-t.clientHeight<100},children:[A?Ve?(0,S.jsxs)(`div`,{className:`assistant-empty`,"data-testid":`assistant-loading`,children:[(0,S.jsx)(o,{}),(0,S.jsx)(`p`,{role:`status`,children:Pe||D.error?`暂时无法加载对话`:`加载中…`})]}):N?.messages.length?N.messages.filter(e=>e.body||[`queued`,`running`,`failed`].includes(e.state)).map(t=>(0,S.jsx)(`div`,{className:`assistant-turn`,children:(0,S.jsxs)(ze,{mine:t.role===`user`&&t.author===e,author:`${t.role===`assistant`?`Tim`:t.author}${t.source===`wecom`?` · 企业微信`:``}`,time:t.createdAt,children:[t.body&&(0,S.jsx)(`div`,{className:`markdown`,children:(0,S.jsx)(ce,{children:t.body})}),t.role===`assistant`&&[`queued`,`running`].includes(t.state)&&(0,S.jsxs)(`span`,{className:`assistant-typing`,"aria-label":`正在回答`,children:[(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{}),(0,S.jsx)(`i`,{})]}),t.state===`failed`&&(0,S.jsx)(n,{error:!0,children:N.runs.find(e=>e.id===t.runId)?.error||`本次回答未完成。`})]})},t.id)):(0,S.jsxs)(`div`,{className:`assistant-empty`,children:[(0,S.jsx)(o,{}),(0,S.jsx)(`p`,{children:`有什么项目问题想聊聊?`})]}):!E.data&&E.loading?(0,S.jsx)(`div`,{className:`assistant-empty`,children:(0,S.jsx)(`p`,{role:`status`,children:`加载中…`})}):O===`debug`?X.map(e=>(0,S.jsx)(_e,{item:e,onReply:e.archivedAt?void 0:()=>{I(e.id),we(``),W(``)}},e.id)):Z&&(0,S.jsx)(_e,{item:Z}),(0,S.jsx)(`div`,{ref:Fe})]}),(0,S.jsx)(n,{error:!0,children:Ne||(A?Pe:``)}),Be?(0,S.jsx)(me,{value:Ce,onChange:we,onSubmit:e=>void Re(e),disabled:V,sendDisabled:z||Ve,label:A?`向Tim提问`:`回复消息`}):O!==`debug`&&Z&&(0,S.jsxs)(`div`,{className:`assistant-archived`,children:[(0,S.jsx)(s,{name:`archive`}),`已归档`]})]})}function _e({item:e,onReply:t}){return(0,S.jsx)(`div`,{"data-testid":`outbox-thread-${e.id}`,children:(0,S.jsxs)(pe,{author:e.box===`debug`?`运行提醒`:`Tim`,time:e.createdAt,children:[(0,S.jsx)(`div`,{className:`markdown`,children:(0,S.jsx)(ce,{children:e.body})}),t&&(0,S.jsx)(`button`,{type:`button`,className:`assistant-debug-reply`,onClick:t,children:`回复`})]})})}export{w as Assistant};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{$ as e,A as t,C as n,D as r,E as i,Et as a,G as o,H as s,L as c,M as l,O as u,P as d,S as f,T as p,Tt as m,V as h,W as g,X as _,_ as v,b as y,g as b,ht as x,j as S,k as C,mt as w,nt as T,p as E,pt as D,rt as O,vt as k,w as A,x as j,xt as ee,yt as M,z as N}from"./index-DiR0ePCJ.js";import{t as P}from"./Markdown-DorC2YjE.js";import{a as te,n as F,o as I,r as ne,t as re}from"./Conversation-BBWm5w-C.js";import{n as ie,t as ae}from"./MessageComposer-DQBDG5yF.js";import{r as oe}from"./WorkspaceTree-B4FMRlCw.js";var L=m(),R=k({cwd:M(),repository:M().nullable(),capturedAt:M(),truncated:x(),files:w(k({path:M(),section:D([`staged`,`working`,`untracked`]),patch:M().max(5e4),binary:x(),truncated:x()})).max(100)}),z=e(),B=k({command:C,diff:R.nullable()});function se({session:e,request:t,onClose:n}){let[r,i]=(0,L.useState)(O),[a,s]=(0,L.useState)(),[c,l]=(0,L.useState)(``);(0,L.useEffect)(()=>{let n=new AbortController,i;s(void 0),l(``);let a=async()=>{try{let o=await t(`web/local-agent-sessions/${e}/diff/${r}`,B,{signal:n.signal});if(n.signal.aborted)return;s(o),[`queued`,`running`].includes(o.command.state)&&(i=setTimeout(()=>void a(),1e3))}catch(e){n.signal.aborted||l(T(e))}};return t(`web/local-agent-sessions/${e}/commands`,C,{method:`POST`,signal:n.signal,body:{id:r,kind:`diff`}}).then(a).catch(e=>{n.signal.aborted||l(T(e))}),()=>{n.abort(),clearTimeout(i)}},[e,t,r]);let u=a?.diff,d=!c&&(!a||[`queued`,`running`].includes(a.command.state));return(0,z.jsx)(g,{id:`workspace-diff`,title:`工作目录改动`,onClose:n,children:(0,z.jsxs)(`div`,{className:`workspace-diff`,children:[(0,z.jsx)(`p`,{className:`muted`,children:`包含此目录内所有未提交改动,也可能包含其他会话或工具的修改。`}),(0,z.jsxs)(`div`,{className:`workspace-diff-toolbar`,children:[(0,z.jsx)(`span`,{className:`muted`,children:u?`读取于 ${new Date(u.capturedAt).toLocaleTimeString()}`:d?`正在从开发机读取…`:``}),(0,z.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>i(O()),children:`刷新`})]}),(0,z.jsx)(o,{error:!0,children:c||a?.command.error}),u&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`code`,{className:`workspace-diff-path`,children:u.cwd}),u.repository?u.files.length?null:(0,z.jsx)(`p`,{children:`当前目录没有未提交改动。`}):(0,z.jsx)(`p`,{children:`此目录不在 Git 仓库中。`}),u.truncated&&(0,z.jsx)(o,{children:`部分内容较大或无法预览,已限制显示范围。完整内容请在开发机查看。`}),u.files.map((e,t)=>(0,z.jsxs)(`details`,{open:t===0,children:[(0,z.jsxs)(`summary`,{children:[(0,z.jsx)(`span`,{children:e.path}),(0,z.jsx)(`small`,{children:{staged:`已暂存`,working:`未暂存`,untracked:`未跟踪`}[e.section]})]}),e.binary?(0,z.jsx)(`p`,{className:`muted`,children:`二进制文件`}):e.patch?(0,z.jsx)(`pre`,{"aria-label":`${e.path} 差异`,children:(0,z.jsx)(`code`,{children:e.patch.split(`
|
|
2
|
+
`).map((e,t)=>(0,z.jsxs)(`span`,{className:e.startsWith(`+`)?`diff-added`:e.startsWith(`-`)?`diff-removed`:e.startsWith(`@@`)?`diff-hunk`:``,children:[e,e?null:`\xA0`]},t))})}):(0,z.jsx)(`p`,{className:`muted`,children:`无可预览的文本差异。`}),e.truncated&&(0,z.jsx)(`small`,{className:`muted`,children:`此文件内容已截断或未展开。`})]},`${e.section}:${e.path}`))]})]})})}var ce=(e,t,n)=>a(`/api/v1/projects/${encodeURIComponent(e)}/local-agent/sessions/${encodeURIComponent(t)}/images/${encodeURIComponent(n)}`);function le({images:e,url:t,remove:n,disabled:r=!1}){return e.length?(0,z.jsx)(`div`,{className:`session-images`,children:e.map(e=>(0,z.jsxs)(`div`,{className:`session-image`,children:[(0,z.jsx)(`a`,{href:t(e.id),target:`_blank`,rel:`noreferrer`,title:e.name,children:(0,z.jsx)(`img`,{src:t(e.id),alt:e.name,loading:`lazy`})}),n&&(0,z.jsx)(`button`,{type:`button`,"aria-label":`移除图片 ${e.name}`,disabled:r,onClick:()=>n(e.id),children:(0,z.jsx)(h,{name:`close`,size:`small`})})]},e.id))}):null}function ue(e,t,n){let[r,i]=(0,L.useState)([]),[a,s]=(0,L.useState)(!1),[c,l]=(0,L.useState)(``),u=`${t}:${e}`,f=(0,L.useRef)(u),p=(0,L.useRef)(!1),m=(0,L.useRef)(null);f.current=u,(0,L.useEffect)(()=>{i([]),l(``)},[u]);async function g(t){if(!p.current&&e){if(t.length+r.length>4)l(`每条消息最多添加 4 张图片。`);else{p.current=!0,s(!0),l(``);try{for(let r of Array.from(t)){if(![`image/png`,`image/jpeg`,`image/webp`].includes(r.type)||r.size>5242880||!r.size)throw Error(`请选择不超过 5 MB 的 PNG、JPEG 或 WebP 图片。`);let t=await new Promise((e,t)=>{let n=new FileReader;n.onload=()=>e(String(n.result).split(`,`,2)[1]),n.onerror=()=>t(Error(`图片读取失败。`)),n.readAsDataURL(r)}),a=await n(`web/local-agent-sessions/${e}/images`,d,{method:`POST`,body:{id:O(),name:r.name.slice(0,200),data:t}});if(f.current!==u)return;i(e=>[...e,a])}}catch(e){f.current===u&&l(T(e))}finally{p.current=!1,s(!1)}}}}let _=n=>ce(t,e,n);return{images:r,busy:a,add:g,clear:()=>{f.current===u&&i([])},picker:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`input`,{ref:m,type:`file`,className:`session-image-file`,accept:`image/png,image/jpeg,image/webp`,multiple:!0,"aria-label":`选择图片`,disabled:e||a,onChange:e=>{e.target.files&&g(e.target.files),e.target.value=``}}),(0,z.jsx)(`button`,{type:`button`,className:`icon-button`,"aria-label":`添加图片`,title:`添加图片,也可粘贴或拖入`,disabled:e||a,onClick:()=>m.current?.click(),children:(0,z.jsx)(h,{name:`attachment`,size:`small`})})]}),preview:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(le,{images:r,url:_,disabled:e||a,remove:e=>i(t=>t.filter(t=>t.id!==e))}),a&&(0,z.jsx)(`small`,{className:`muted`,children:`正在上传图片…`}),(0,z.jsx)(o,{error:!0,children:c})]})}}function de({message:e,session:t,request:n,refresh:r}){let[i,a]=(0,L.useState)(!1),[s,c]=(0,L.useState)(e.body),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(``),p=(0,L.useRef)(void 0),m=e.queue;if(!m)return null;let h={offered:`待本地接收`,received:`待本地接收`,queued:`排队中`,dispatching:`正在发送`,running:`执行中`,cancelled:`已撤回`,uncertain:`需要核对`};async function g(i){let o=JSON.stringify({inputId:e.id.replace(/^input:/,``),expectedRevision:m.revision,...i===`queue-edit`?{body:s}:{}}),c=`${i}:${o}`;p.current?.fingerprint!==c&&(p.current={fingerprint:c,id:O()}),u(!0),f(``);try{await n(`web/local-agent-sessions/${t}/commands`,C,{method:`POST`,body:{id:p.current.id,kind:i,argument:o}}),a(!1),p.current=void 0,r()}catch(e){f(T(e))}finally{u(!1)}}return(0,z.jsxs)(`div`,{className:`queued-message`,children:[h[m.state]&&(0,z.jsx)(`small`,{className:`muted`,children:h[m.state]}),i?(0,z.jsxs)(`div`,{className:`queued-message-editor`,children:[(0,z.jsx)(`textarea`,{"aria-label":`编辑待发送消息`,value:s,onChange:e=>c(e.target.value),disabled:l||!m.editable,autoFocus:!0}),(0,z.jsxs)(`div`,{className:`queued-message-actions`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:l||!m.editable||!s.trim(),onClick:()=>void g(`queue-edit`),children:`保存修改`}),(0,z.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>a(!1),children:`取消编辑`})]})]}):m.editable&&(0,z.jsxs)(`div`,{className:`queued-message-actions`,children:[(0,z.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>{c(e.body),a(!0)},children:`编辑`}),(0,z.jsx)(`button`,{type:`button`,disabled:l,onClick:()=>void g(`queue-cancel`),children:`撤回`})]}),(0,z.jsx)(o,{error:!0,children:d})]})}function V(e){if(e<1e3)return`不到 1 秒`;let t=Math.floor(e/1e3),n=Math.floor(t/60),r=Math.floor(n/60);return[r?`${r} 小时`:``,n%60?`${n%60} 分`:``,t%60?`${t%60} 秒`:``].filter(Boolean).join(` `)}function fe({children:e}){return(0,z.jsx)(`div`,{className:`computer-divider`,children:(0,z.jsx)(`span`,{children:e})})}function pe({message:e}){let t=e.state===`succeeded`?`已工作`:e.state===`interrupted`?`已停止`:e.state===`failed`?`执行失败`:`需要核对`;return(0,z.jsxs)(fe,{children:[t,e.activity?.durationMs===void 0?``:` · ${V(e.activity.durationMs)}`]})}var me={offered:`待本地接收`,pending:`待投递`,human_routed:`未送达本地`,failed:`失败`,uncertain:`需要核对`};function he({messages:e,renderQuestion:t,imageUrl:n,renderQueue:r}){let i=new Map(e.filter(e=>e.activity?.kind===`turn`).map(e=>[e.activity.turnId,e])),a=new Map,o=new Set(e.flatMap(e=>{let t=e.question?.planSource;return t?[JSON.stringify([t.turnId,t.itemId])]:[]})),s=new Set(e.flatMap(e=>{let t=e.activity;return t?.kind===`commentary`&&o.has(JSON.stringify([t.turnId,t.itemId]))?[JSON.stringify([t.turnId,e.body])]:[]}));for(let t of e)t.activity?.kind===`answer`&&!a.has(t.activity.turnId)&&a.set(t.activity.turnId,t.id);return(0,z.jsx)(`div`,{className:`computer-messages`,children:e.map(e=>{let c=e.activity;if(c?.kind===`commentary`&&(o.has(JSON.stringify([c.turnId,c.itemId]))||s.has(JSON.stringify([c.turnId,e.body]))))return null;if(e.role===`system`)return(0,z.jsx)(fe,{children:e.body},e.id);if(c?.kind===`turn`)return a.has(c.turnId)?null:(0,z.jsx)(pe,{message:e},e.id);if(e.role===`user`)return(0,z.jsxs)(re,{mine:!0,author:`你`,time:e.createdAt,children:[n&&e.images?.length?(0,z.jsx)(le,{images:e.images,url:n}):null,(0,z.jsx)(`div`,{className:`markdown`,children:(0,z.jsx)(P,{children:e.body})}),e.queue&&r?r(e):me[e.state]&&(0,z.jsx)(I,{label:me[e.state],state:e.state})]},e.id);if(c?.kind===`tool`)return(0,z.jsxs)(`details`,{className:`computer-tool`,children:[(0,z.jsxs)(`summary`,{title:c.label,children:[(0,z.jsx)(h,{name:`chevron`,size:`small`}),(0,z.jsx)(`span`,{className:`computer-tool-label`,children:c.label??`工具调用`}),(0,z.jsxs)(`span`,{className:`computer-tool-status`,children:[e.state===`running`?`进行中`:e.state===`failed`?`失败`:e.state===`interrupted`?`已停止`:e.state===`uncertain`?`需核对`:``,c.durationMs!==void 0&&(0,z.jsx)(`span`,{children:V(c.durationMs)})]})]}),(0,z.jsx)(`pre`,{children:e.body})]},e.id);let l=c?.kind===`answer`&&a.get(c.turnId)===e.id?i.get(c.turnId):void 0;return(0,z.jsxs)(L.Fragment,{children:[l&&(0,z.jsx)(pe,{message:l}),(0,z.jsx)(`article`,{className:`computer-agent-message ${c?.kind===`commentary`?`computer-commentary`:``} ${e.question?`question-bubble`:``}`,children:e.question?t(e.question):(0,z.jsx)(`div`,{className:`markdown`,children:(0,z.jsx)(P,{children:e.body})})})]},e.id)})})}var H={codex:{name:`Codex`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/openai.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eOpenAI%3c/title%3e%3cpath%20d='M9.205%208.658v-2.26c0-.19.072-.333.238-.428l4.543-2.616c.619-.357%201.356-.523%202.117-.523%202.854%200%204.662%202.212%204.662%204.566%200%20.167%200%20.357-.024.547l-4.71-2.759a.797.797%200%2000-.856%200l-5.97%203.473zm10.609%208.8V12.06c0-.333-.143-.57-.429-.737l-5.97-3.473%201.95-1.118a.433.433%200%2001.476%200l4.543%202.617c1.309.76%202.189%202.378%202.189%203.948%200%201.808-1.07%203.473-2.76%204.163zM7.802%2012.703l-1.95-1.142c-.167-.095-.239-.238-.239-.428V5.899c0-2.545%201.95-4.472%204.591-4.472%201%200%201.927.333%202.712.928L8.23%205.067c-.285.166-.428.404-.428.737v6.898zM12%2015.128l-2.795-1.57v-3.33L12%208.658l2.795%201.57v3.33L12%2015.128zm1.796%207.23c-1%200-1.927-.332-2.712-.927l4.686-2.712c.285-.166.428-.404.428-.737v-6.898l1.974%201.142c.167.095.238.238.238.428v5.233c0%202.545-1.974%204.472-4.614%204.472zm-5.637-5.303l-4.544-2.617c-1.308-.761-2.188-2.378-2.188-3.948A4.482%204.482%200%20014.21%206.327v5.423c0%20.333.143.571.428.738l5.947%203.449-1.95%201.118a.432.432%200%2001-.476%200zm-.262%203.9c-2.688%200-4.662-2.021-4.662-4.519%200-.19.024-.38.047-.57l4.686%202.71c.286.167.571.167.856%200l5.97-3.448v2.26c0%20.19-.07.333-.237.428l-4.543%202.616c-.619.357-1.356.523-2.117.523zm5.899%202.83a5.947%205.947%200%20005.827-4.756C22.287%2018.339%2024%2015.84%2024%2013.296c0-1.665-.713-3.282-1.998-4.448.119-.5.19-.999.19-1.498%200-3.401-2.759-5.947-5.946-5.947-.642%200-1.26.095-1.88.31A5.962%205.962%200%200010.205%200a5.947%205.947%200%2000-5.827%204.757C1.713%205.447%200%207.945%200%2010.49c0%201.666.713%203.283%201.998%204.448-.119.5-.19%201-.19%201.499%200%203.401%202.759%205.946%205.946%205.946.642%200%201.26-.095%201.88-.309a5.96%205.96%200%20004.162%201.713z'%3e%3c/path%3e%3c/svg%3e`},claude:{name:`Claude Code`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/claude.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eClaude%3c/title%3e%3cpath%20d='M4.709%2015.955l4.72-2.647.08-.23-.08-.128H9.2l-.79-.048-2.698-.073-2.339-.097-2.266-.122-.571-.121L0%2011.784l.055-.352.48-.321.686.06%201.52.103%202.278.158%201.652.097%202.449.255h.389l.055-.157-.134-.098-.103-.097-2.358-1.596-2.552-1.688-1.336-.972-.724-.491-.364-.462-.158-1.008.656-.722.881.06.225.061.893.686%201.908%201.476%202.491%201.833.365.304.145-.103.019-.073-.164-.274-1.355-2.446-1.446-2.49-.644-1.032-.17-.619a2.97%202.97%200%2001-.104-.729L6.283.134%206.696%200l.996.134.42.364.62%201.414%201.002%202.229%201.555%203.03.456.898.243.832.091.255h.158V9.01l.128-1.706.237-2.095.23-2.695.08-.76.376-.91.747-.492.584.28.48.685-.067.444-.286%201.851-.559%202.903-.364%201.942h.212l.243-.242.985-1.306%201.652-2.064.73-.82.85-.904.547-.431h1.033l.76%201.129-.34%201.166-1.064%201.347-.881%201.142-1.264%201.7-.79%201.36.073.11.188-.02%202.856-.606%201.543-.28%201.841-.315.833.388.091.395-.328.807-1.969.486-2.309.462-3.439.813-.042.03.049.061%201.549.146.662.036h1.622l3.02.225.79.522.474.638-.079.485-1.215.62-1.64-.389-3.829-.91-1.312-.329h-.182v.11l1.093%201.068%202.006%201.81%202.509%202.33.127.578-.322.455-.34-.049-2.205-1.657-.851-.747-1.926-1.62h-.128v.17l.444.649%202.345%203.521.122%201.08-.17.353-.608.213-.668-.122-1.374-1.925-1.415-2.167-1.143-1.943-.14.08-.674%207.254-.316.37-.729.28-.607-.461-.322-.747.322-1.476.389-1.924.315-1.53.286-1.9.17-.632-.012-.042-.14.018-1.434%201.967-2.18%202.945-1.726%201.845-.414.164-.717-.37.067-.662.401-.589%202.388-3.036%201.44-1.882.93-1.086-.006-.158h-.055L4.132%2018.56l-1.13.146-.487-.456.061-.746.231-.243%201.908-1.312-.006.006z'%3e%3c/path%3e%3c/svg%3e`},cursor:{name:`Cursor`,logo:`data:image/svg+xml,%3csvg%20fill='currentColor'%20fill-rule='evenodd'%20height='1em'%20style='flex:none;line-height:1'%20viewBox='0%200%2024%2024'%20width='1em'%20xmlns='http://www.w3.org/2000/svg'%3e%3cmetadata%3eMIT%20License%20Copyright%20(c)%202023%20LobeHub%20Permission%20is%20hereby%20granted,%20free%20of%20charge,%20to%20any%20person%20obtaining%20a%20copy%20of%20this%20software%20and%20associated%20documentation%20files%20(the%20'Software'),%20to%20deal%20in%20the%20Software%20without%20restriction,%20including%20without%20limitation%20the%20rights%20to%20use,%20copy,%20modify,%20merge,%20publish,%20distribute,%20sublicense,%20and/or%20sell%20copies%20of%20the%20Software,%20and%20to%20permit%20persons%20to%20whom%20the%20Software%20is%20furnished%20to%20do%20so,%20subject%20to%20the%20following%20conditions:%20The%20above%20copyright%20notice%20and%20this%20permission%20notice%20shall%20be%20included%20in%20all%20copies%20or%20substantial%20portions%20of%20the%20Software.%20THE%20SOFTWARE%20IS%20PROVIDED%20'AS%20IS',%20WITHOUT%20WARRANTY%20OF%20ANY%20KIND,%20EXPRESS%20OR%20IMPLIED,%20INCLUDING%20BUT%20NOT%20LIMITED%20TO%20THE%20WARRANTIES%20OF%20MERCHANTABILITY,%20FITNESS%20FOR%20A%20PARTICULAR%20PURPOSE%20AND%20NONINFRINGEMENT.%20IN%20NO%20EVENT%20SHALL%20THE%20AUTHORS%20OR%20COPYRIGHT%20HOLDERS%20BE%20LIABLE%20FOR%20ANY%20CLAIM,%20DAMAGES%20OR%20OTHER%20LIABILITY,%20WHETHER%20IN%20AN%20ACTION%20OF%20CONTRACT,%20TORT%20OR%20OTHERWISE,%20ARISING%20FROM,%20OUT%20OF%20OR%20IN%20CONNECTION%20WITH%20THE%20SOFTWARE%20OR%20THE%20USE%20OR%20OTHER%20DEALINGS%20IN%20THE%20SOFTWARE.%20Source:%20https://raw.githubusercontent.com/lobehub/lobe-icons/ea434b96e75813517b377825e01c0df61dee8836/packages/static-svg/icons/claude.svg%20Teammy:%20added%20license%20metadata;%20geometry%20unchanged.%3c/metadata%3e%3ctitle%3eCursor%3c/title%3e%3cpath%20d='M22.106%205.68L12.5.135a.998.998%200%2000-.998%200L1.893%205.68a.84.84%200%2000-.419.726v11.186c0%20.3.16.577.42.727l9.607%205.547a.999.999%200%2000.998%200l9.608-5.547a.84.84%200%2000.42-.727V6.407a.84.84%200%2000-.42-.726zm-.603%201.176L12.228%2022.92c-.063.108-.228.064-.228-.061V12.34a.59.59%200%2000-.295-.51l-9.11-5.26c-.107-.062-.063-.228.062-.228h18.55c.264%200%20.428.286.296.514z'%3e%3c/path%3e%3c/svg%3e`},pi:{name:`Pi`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2024%2024'%3e%3cpath%20fill='currentColor'%20d='M3%205h18v3h-3v9c0%201%20.5%201.5%201.5%201.5H21V21h-2c-3%200-4-1.5-4-4V8H9v6c0%204-1.5%206.5-5%207l-1-2.5C5.5%2018%206%2016.5%206%2014V8H3z'/%3e%3c/svg%3e`},opencode:{name:`OpenCode`,logo:`data:image/svg+xml,%3csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='96%2064%20288%20384'%20fill='%23393936'%3e%3cpath%20d='M320%20224V352H192V224H320Z'%20opacity='.4'/%3e%3cpath%20fill-rule='evenodd'%20d='M384%20416H128V96H384V416ZM320%20160H192V352H320V160Z'/%3e%3c/svg%3e`}};function ge({provider:e}){let{name:t,logo:n}=H[e];return(0,z.jsx)(`img`,{className:`agent-logo`,src:n,alt:t,title:t,"data-provider":e,width:24,height:24})}function _e({disabled:e,onSend:t,initialValue:n=``,placeholder:r}){let[i,a]=(0,L.useState)(n),[o,s]=(0,L.useState)(!!n),c=`其他回答`,l=(0,L.useRef)(null),u=(0,L.useCallback)(e=>{if(!l.current)return;let t=document.createElement(`canvas`).getContext(`2d`);if(!t)return;t.font=getComputedStyle(e).font;let n=Math.max(...(i||`${c}…`).split(`
|
|
3
|
+
`).map(e=>t.measureText(e).width));l.current.style.setProperty(`--reply-width`,`${Math.ceil(n+(o?52:26))}px`)},[i,o,c]),d=ie(i,u);return(0,z.jsxs)(`form`,{ref:l,className:`inline-reply${o?` active`:``}`,onFocus:()=>s(!0),onBlur:e=>{!i&&!e.currentTarget.contains(e.relatedTarget)&&s(!1)},onSubmit:n=>{n.preventDefault(),!e&&i.trim()&&t(i.trim()).then(e=>{e&&a(``)})},children:[(0,z.jsx)(`textarea`,{ref:d,rows:1,"aria-label":`自定义回答`,placeholder:r??`${c}…`,value:i,disabled:e,onChange:e=>a(e.target.value),onKeyDown:t=>{t.key===`Enter`&&!t.shiftKey&&!t.nativeEvent.isComposing&&(t.preventDefault(),!e&&i.trim()&&t.currentTarget.form?.requestSubmit())}}),o&&(0,z.jsx)(`button`,{className:`inline-reply-send`,type:`submit`,disabled:e||!i.trim(),"aria-label":`发送${c}`,title:`发送${c}`,children:(0,z.jsx)(h,{name:`send`,size:`small`})})]})}function ve({question:e,session:t,request:n,refresh:r}){let[i,a]=(0,L.useState)({}),[s,c]=(0,L.useState)({}),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),[g,_]=(0,L.useState)(``),v=(0,L.useRef)(null),y=(0,L.useRef)(!1),b=(0,L.useRef)(void 0);(0,L.useEffect)(()=>{if(e.state!==`pending`||y.current||!v.current)return;let r=!1,i=()=>{if(!r||document.visibilityState!==`visible`||!v.current)return;let i=v.current.getBoundingClientRect();i.bottom>0&&i.top<innerHeight&&n(`web/local-agent-sessions/${t}/questions/${e.id}/presented`,k({ok:x()}),{method:`POST`}).then(()=>{y.current=!0}).catch(e=>u(T(e)))},a=new IntersectionObserver(e=>{r=e.some(e=>e.isIntersecting),i()});return a.observe(v.current),document.addEventListener(`visibilitychange`,i),()=>{a.disconnect(),document.removeEventListener(`visibilitychange`,i)}},[e.id,e.state,t,n]);async function S(i){let a=JSON.stringify(i);b.current?.fingerprint!==a&&(b.current={fingerprint:a,value:{...i,id:O()}}),f(!0),u(``);try{return await n(`web/local-agent-sessions/${t}/questions/${e.id}/answers`,ee(),{method:`POST`,body:b.current.value}),b.current=void 0,r(),!0}catch(e){return u(T(e)),!1}finally{f(!1)}}let C=e.response,w=e.state===`answered`,E=[`expired`,`cancelled`].includes(e.state),D=[`human_routed`,`failed`,`handled`].includes(e.submissionState??``)&&!w,A=e.state===`pending`&&(!C||D),j=e.kind===`plan`,M=e.actions?.find(e=>e.id===C?.actionId),N=E?`已过期`:e.state===`uncertain`||e.submissionState===`uncertain`?`需核对`:w?j?M?.label??`已处理`:e.approval?C?.decision===!0?`已允许`:C?.decision===!1?`已拒绝`:`已处理`:M?M.label:C?``:`已回答`:D?`请重新提交`:C?`正在提交`:``,te=E||C?.decision===!1||D?`close`:w?`check`:`clock`,F=e.questions.length>1||e.questions.some(e=>e.multiSelect),I=(t=i)=>S({body:e.questions.length===1?t[e.questions[0].id]||(s[e.questions[0].id]??[]).join(`、`):JSON.stringify(t),...e.kind||e.questions.some(e=>e.multiSelect)?{answers:t}:{},...e.questions.some(e=>e.multiSelect)?{selections:s}:{}});return(0,z.jsxs)(`div`,{className:`native-question ${j?`native-plan`:``}`,ref:v,children:[j?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`div`,{className:`native-plan-heading`,children:[(0,z.jsx)(h,{name:`file`,size:`small`}),(0,z.jsx)(`span`,{children:`实施计划`})]}),A?(0,z.jsx)(`div`,{className:`native-plan-content markdown`,children:(0,z.jsx)(P,{children:e.plan??``})}):(0,z.jsxs)(`details`,{className:`native-plan-history markdown`,children:[(0,z.jsx)(`summary`,{children:`查看计划`}),(0,z.jsx)(P,{children:e.plan??``})]}),A&&(0,z.jsxs)(z.Fragment,{children:[!p&&(0,z.jsx)(`div`,{className:`question-actions native-plan-actions ${e.actions&&e.actions.length>3?`native-plan-actions-expanded`:``}`,children:e.actions?.map(e=>(0,z.jsx)(`button`,{type:`button`,disabled:d,title:e.description,className:e.id===`implement`?`primary`:``,onClick:()=>e.id===`revise`?m(!0):void S({body:e.label,actionId:e.id}),children:e.label},e.id))}),!p&&e.actions?.find(e=>e.id===`implement`)?.description&&(0,z.jsxs)(`small`,{className:`native-plan-note muted`,children:[`开始实施:`,e.actions.find(e=>e.id===`implement`).description]}),p&&(0,z.jsxs)(`form`,{className:`native-plan-feedback`,onSubmit:e=>{e.preventDefault(),S({body:g,actionId:`revise`})},children:[(0,z.jsxs)(`label`,{children:[`修改意见`,(0,z.jsx)(`textarea`,{autoFocus:!0,value:g,onChange:e=>_(e.target.value),placeholder:`说明希望调整的部分,Agent 将修改后再次请求确认`})]}),(0,z.jsxs)(`div`,{className:`question-actions native-plan-feedback-actions`,children:[(0,z.jsx)(`button`,{className:`primary`,disabled:d||!g.trim(),children:`提交修改意见`}),(0,z.jsx)(`button`,{type:`button`,disabled:d,onClick:()=>m(!1),children:`返回计划`})]})]})]}),!A&&C?.actionId===`revise`&&C.answers.feedback&&(0,z.jsx)(`div`,{className:`question-response`,children:C.answers.feedback})]}):(0,z.jsxs)(z.Fragment,{children:[e.questions.map(t=>(0,z.jsxs)(`div`,{className:`native-question-part`,children:[(0,z.jsx)(`p`,{className:e.approval?`native-approval-detail`:``,children:t.text}),A&&(0,z.jsx)(`div`,{className:`question-options ${e.approval?`native-approval-options`:Object.values(t.descriptions??{}).some(Boolean)?`question-options-described`:``}`,children:(e.approval?[`允许`,`拒绝`]:t.options).map(n=>(0,z.jsxs)(`button`,{type:`button`,disabled:d,"aria-pressed":t.multiSelect?s[t.id]?.includes(n)??!1:i[t.id]===n,onClick:()=>{if(t.multiSelect){c(e=>({...e,[t.id]:e[t.id]?.includes(n)?e[t.id].filter(e=>e!==n):[...e[t.id]??[],n]}));return}let r={...i,[t.id]:n};a(r),e.approval?S({body:n,decision:n===`允许`}):F||I(r)},children:[(0,z.jsxs)(`span`,{className:`question-option-label`,children:[t.multiSelect&&(0,z.jsx)(`span`,{"aria-hidden":`true`,className:`question-check`,children:s[t.id]?.includes(n)&&(0,z.jsx)(h,{name:`check`,size:`small`})}),n]}),t.descriptions?.[n]&&(0,z.jsx)(`small`,{children:t.descriptions[n]})]},n))}),!e.approval&&t.freeText&&A&&(0,z.jsx)(_e,{initialValue:t.initialValue,placeholder:t.placeholder,disabled:d,onSend:async e=>{let n={...i,[t.id]:e};return a(n),F?!0:I(n)}}),A&&F&&i[t.id]&&!t.options.includes(i[t.id])&&(0,z.jsx)(`small`,{children:i[t.id]}),!A&&!e.approval&&(C?.answers[t.id]||C?.selections?.[t.id]?.length)&&(0,z.jsxs)(`div`,{className:`question-response`,children:[(0,z.jsx)(h,{name:w?`check`:`clock`,size:`small`}),(0,z.jsx)(`span`,{children:[...C.selections?.[t.id]??[],C.answers[t.id]].filter(Boolean).join(`、`)})]})]},t.id)),A&&!e.approval&&e.actions?.length&&(0,z.jsx)(`div`,{className:`question-actions`,children:e.actions.map(e=>(0,z.jsx)(`button`,{disabled:d,onClick:()=>void S({body:e.label,actionId:e.id}),children:e.label},e.id))}),A&&!e.approval&&F&&(0,z.jsx)(`div`,{className:`question-actions`,children:(0,z.jsx)(`button`,{disabled:d||e.questions.some(e=>!i[e.id]?.trim()&&!s[e.id]?.length),onClick:()=>void I(),children:`回答`})}),A&&e.approval&&e.autoApprove!==!1&&(0,z.jsx)(`small`,{className:`muted`,children:`60 秒后自动允许`})]}),N&&(0,z.jsxs)(`small`,{className:`question-result`,children:[(0,z.jsx)(h,{name:te,size:`small`}),N]}),(0,z.jsx)(o,{error:!0,children:l})]})}var U={minimal:`极低`,low:`低`,medium:`中`,high:`高`,xhigh:`极高`,max:`最高`,ultra:`极致`,none:`无`,off:`关闭`};function W({id:e,label:t,current:n,options:r,disabled:i,onSelect:a}){let o=r.find(e=>e.value===n);return(0,z.jsx)(b,{id:`${e}-menu`,triggerId:e,placement:`top`,className:`composer-menu composer-choice`,label:`选择${t}`,disabled:i,routeKey:n,trigger:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`span`,{title:`${t}:${o?.label??n}`,children:o?.shortLabel??o?.label??n}),(0,z.jsx)(h,{name:`chevronDown`,size:`small`})]}),children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`div`,{className:`composer-menu-heading`,children:t}),r.map(t=>(0,z.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),a(t.value)},children:[(0,z.jsxs)(`span`,{className:`composer-option-copy`,children:[(0,z.jsx)(`span`,{children:t.label}),t.description&&(0,z.jsx)(`small`,{children:t.description})]}),t.value===n&&(0,z.jsx)(h,{name:`check`,size:`small`})]},t.value))]})})}function ye({session:e,models:t,busy:n,available:r,online:i,commands:a,controls:o,draft:s,onInsert:c,onConfig:l}){let[u,d]=(0,L.useState)(!1);(0,L.useEffect)(()=>{/^[/$]([^\s]*)$/.exec(s)?d(!0):d(!1)},[s]);let f=e.config.model??e.effectiveConfig?.model,p=t.find(e=>e.id===f||e.resolvedModel===f)??(e.config.model?void 0:t.find(e=>e.isDefault)),m=n||!r,g=e.provider===`claude`,_=e.provider===`cursor`,v=e.provider===`pi`,y=o??S(e.provider),x=p?.effortLabel??`思考强度`,C=e=>p?.effortLabel?e:U[e]??e,w=e.appliedRevision===e.revision?e.effectiveConfig?.mode:void 0,T=t.find(e=>e.isDefault)?.id??(e.config.model?null:e.effectiveConfig?.model),E=t.find(e=>e.id===T)?.name??T,D=e=>g?e.replace(/^Claude\s+/,``):e,O=[{value:``,label:E?`默认 · ${E}`:t.length?`默认模型`:`模型未获取`,shortLabel:E?D(E):t.length?`默认模型`:`模型`},...t.map(e=>({value:e.id,label:e.name,shortLabel:D(e.name)}))];e.config.model&&!t.some(t=>t.id===e.config.model)&&O.push({value:e.config.model,label:e.config.model,shortLabel:D(e.config.model)});let k=p?.id===e.effectiveConfig?.model?e.effectiveConfig?.effort:p?.defaultEffort,A=[{value:``,label:k?`默认 · ${C(k)}`:`默认${x}`,shortLabel:k?C(k):p?.effortLabel??`强度`},...(p?.efforts??[]).map(e=>({value:e,label:C(e)}))];return e.config.effort&&!A.some(t=>t.value===e.config.effort)&&A.push({value:e.config.effort,label:C(e.config.effort)}),(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(b,{id:`session-commands`,triggerId:`session-command-trigger`,label:`命令与 Skills`,placement:`top`,className:`composer-menu composer-commands`,routeKey:e.id,trigger:(0,z.jsx)(h,{name:`command`,size:`small`}),open:u,onOpenChange:d,focusFirst:!1,disabled:m||!i,children:e=>(0,z.jsxs)(z.Fragment,{children:[[...a].sort((e,t)=>e.name.localeCompare(t.name,`en`)).map(t=>(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,title:[t.description,t.path].filter(Boolean).join(`
|
|
4
|
+
`),onClick:()=>{e(),c(t)},children:(0,z.jsxs)(`span`,{className:`composer-command-row`,children:[(0,z.jsxs)(`span`,{className:`composer-command-name`,children:[t.prefix??(t.kind===`skill`?`$`:`/`),t.name]}),(0,z.jsx)(`small`,{children:t.description})]})},`${t.kind}:${t.path??t.name}`)),!a.length&&(0,z.jsx)(`div`,{className:`composer-menu-heading`,children:`尚未获取命令`})]})}),(0,z.jsx)(W,{id:`session-model`,label:`模型`,current:e.config.model??``,options:O,disabled:m,onSelect:n=>{let r=t.find(e=>e.id===n);l({...e.config,model:n||null,..._?{options:{}}:{},effort:e.config.effort&&r?.efforts.includes(e.config.effort)?e.config.effort:null})}}),(!_&&!v&&e.provider!==`opencode`||(p?.efforts.length??0)>0||!!e.config.effort)&&(0,z.jsx)(W,{id:`session-effort`,label:x,current:e.config.effort??``,options:A,disabled:m,onSelect:t=>l({...e.config,effort:t||null})}),p?.options?.map(t=>(0,z.jsx)(W,{id:`session-option-${t.id}`,label:t.name,current:e.config.options?.[t.id]??``,options:[{value:``,label:`默认 · ${t.choices.find(e=>e.value===t.defaultValue)?.label??t.defaultValue}`},...t.choices],disabled:m,onSelect:n=>{let r={...e.config.options};n?r[t.id]=n:delete r[t.id],l({...e.config,options:r})}},t.id)),y.map(t=>(0,z.jsx)(W,{id:t.key===`mode`&&!g?`session-mode`:`session-permission`,label:t.label,current:t.key===`mode`?w??e.config.mode??t.defaultValue:e.config.permission,options:t.choices,disabled:m,onSelect:n=>l(t.key===`mode`?{...e.config,mode:n||void 0}:{...e.config,permission:n})},t.key))]})}var be=k({taskRoot:M().nullable().default(null),online:x(),computer:k({id:M(),name:M(),platform:M()}).nullable(),capabilities:w(M()),models:w(r),providers:w(u).default([]),catalogs:w(i).default([]),directories:w(f),sessions:w(p)}),xe=k({ok:x()}),Se={idle:`空闲`,working:`工作中`,waiting:`等待回答`,queued:`等待执行`,uncertain:`需要核对`,human:`人工处理`,offered:`待本地接收`,accepted:`本地已接手`,human_routed:`未送达本地`,pending:`待投递`,sent:`已发送`,succeeded:`已完成`,running:`进行中`,failed:`失败`};function Ce(){let{request:e}=j(),t=(0,L.useCallback)(t=>e(`web/local-agent-settings`,n,{signal:t}),[e]),r=_(t,3e4);return r.error?(0,z.jsx)(o,{error:!0,children:r.error}):r.data?r.data.accessible?(0,z.jsx)(G,{}):(0,z.jsx)(N,{title:`本项目暂未向你开放本地 Agent 功能`}):null}function G(){let e=j(),[t,n]=(0,L.useState)(()=>new Set),[r,i]=(0,L.useState)(()=>({project:e.projectId,directory:new URLSearchParams(location.search).get(`directory`)??``,session:new URLSearchParams(location.search).get(`session`)??``})),[u,d]=(0,L.useState)(``),[f,m]=(0,L.useState)(!1),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(!1),[D,k]=(0,L.useState)(!1),[M,N]=(0,L.useState)(``),[P,re]=(0,L.useState)(``),[ie,R]=(0,L.useState)(!1),[B,le]=(0,L.useState)(`codex`),[V,fe]=(0,L.useState)(``),[pe,me]=(0,L.useState)(``),H=(0,L.useRef)(null),_e=(0,L.useRef)(!0),U=(0,L.useRef)(void 0),W=(0,L.useRef)(O()),Ce=(0,L.useCallback)(async t=>[{...await e.request(`web/local-agent-computer`,be,{signal:t}),project:e.projectId}],[e]),G=_(Ce,3e3),K=G.data?.find(e=>e.project===r.project),q=K?.directories.find(e=>e.id===r.directory);y(r.project);let J=(0,L.useCallback)((e,t,n)=>y(r.project).request(e,t,n),[r.project]),Y=ue(r.session,r.project,J),Ee=(0,L.useCallback)(e=>r.session?J(`web/local-agent-sessions/${r.session}`,A,{signal:e}):Promise.resolve(null),[J,r.session]),X=_(Ee,15e3),[De,Oe]=(0,L.useState)(),Z=De?.session.id===r.session&&(!X.data||De.cursor>=X.data.cursor)?De:X.data;(0,L.useEffect)(()=>{if(!r.session)return;let e=new EventSource(a(`/api/v1/projects/${encodeURIComponent(r.project)}/web/local-agent-sessions/${encodeURIComponent(r.session)}/events`)),t=!0;return e.addEventListener(`snapshot`,e=>{try{let n=A.parse(JSON.parse(e.data));t&&Oe(e=>e?.session.id===n.session.id&&e.cursor>n.cursor?e:n)}catch(e){d(T(e))}}),()=>{t=!1,e.close()}},[r.project,r.session]),(0,L.useEffect)(()=>{_e.current=!0},[r.project,r.session]),(0,L.useEffect)(()=>{_e.current&&H.current&&(H.current.scrollTop=H.current.scrollHeight)},[Z?.cursor,Z?.messages.length]);let Q=Z?.session,$=K?.capabilities.includes(`local-sessions-v1`),ke=(t,n,r=``)=>{i({project:t,directory:n,session:r}),w(!1),R(!1),me(``),N(``),d(``);let a=new URL(location.href);a.searchParams.set(`directory`,n),r?a.searchParams.set(`session`,r):a.searchParams.delete(`session`),t===e.projectId&&history.replaceState(null,``,a)};(0,L.useEffect)(()=>{if(!r.directory&&G.data?.[0]?.directories[0]){let e=G.data[0],t=e.directories[0],n=e.sessions.find(e=>e.id===r.session);ke(e.project,n?.directory??t.id,n?.id??t.defaultSession)}},[G.data]),(0,L.useEffect)(()=>{if(!Q)return;let e=()=>{document.visibilityState===`visible`&&J(`web/local-agent-sessions/${Q.id}/read`,xe,{method:`POST`}).catch(e=>d(T(e)))};return e(),document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[Q?.id,Z?.messages.at(-1)?.seq,J]);async function Ae(e){m(!0),d(``);try{await e(),await Promise.all([X.reload(),G.reload()])}catch(e){d(T(e))}finally{m(!1)}}let[je,Me]=(0,L.useState)(null);(0,L.useEffect)(()=>Me(null),[Q?.id]);let Ne=K?.catalogs.find(e=>e.provider===(Q?.provider??`codex`)&&(Q?.cwd?e.cwd===Q.cwd:e.directory===(Q?.executionDirectory??Q?.directory))),Pe=Ne?.commands??[],Fe=Ne?.models??K?.providers.find(e=>e.id===Q?.provider)?.models??(Q?.provider===`codex`?K?.models??[]:[]),Ie=!!(Fe.find(e=>e.id===(Q?.config.model??Q?.effectiveConfig?.model))??(Q?.config.model?void 0:Fe.find(e=>e.isDefault)))?.images&&!!K?.capabilities.includes(`local-agent-images-v1`),Le=new Map;for(let e of G.data??[]){let t=e.computer?.id??`unknown:${e.project}`;Le.set(t,[...Le.get(t)??[],e])}return(0,z.jsxs)(ne,{className:`computers-layout`,testId:`computers-page`,label:`本地会话`,tree:!0,navigation:(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(E,{title:`电脑`,icon:`computers`,children:(0,z.jsx)(b,{id:`computer-create-menu`,triggerId:`computer-create`,label:`新建`,trigger:(0,z.jsx)(h,{name:`plus`}),className:`computer-create-menu`,routeKey:r.directory,children:e=>(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,disabled:!q||!$,onClick:()=>{e(),R(!0),le(q?.provider??`codex`),fe(``),S(!1),w(!1),d(``)},children:`新建会话`}),(0,z.jsx)(`button`,{type:`button`,role:`menuitem`,onClick:()=>{e(),S(!0),R(!1),w(!1)},children:`接入目录`})]})})}),(0,z.jsx)(`div`,{className:`assistant-message-scroll computer-tree`,role:`tree`,"aria-label":`电脑与会话`,onKeyDown:oe,children:[...Le.entries()].map(([e,i])=>(0,z.jsxs)(`div`,{role:`none`,children:[(0,z.jsxs)(`div`,{className:`computer-device`,children:[(0,z.jsx)(`span`,{className:`computer-connection ${i.some(e=>e.online)?`online`:``}`,role:`img`,"aria-label":i.some(e=>e.online)?`在线`:`离线`,title:i.some(e=>e.online)?`在线`:`离线`,children:(0,z.jsx)(h,{name:`device`,size:`small`})}),(0,z.jsx)(`span`,{title:i[0].computer?.name,children:i[0].computer?.name??`已连接客户端`})]}),i.map(e=>(0,z.jsx)(`div`,{role:`none`,children:e.directories.map(i=>{let a=`${e.project}/${i.id}`,o=!t.has(a);return(0,z.jsxs)(`div`,{role:`none`,children:[(0,z.jsxs)(v,{className:`tree-item tree-folder`,role:`treeitem`,"aria-level":1,"aria-expanded":o,style:{"--tree-level":1},leading:(0,z.jsx)(`span`,{className:`tree-chevron ${o?`expanded`:``}`,children:(0,z.jsx)(h,{name:`chevron`,size:`small`})}),onClick:()=>n(e=>{let t=new Set(e);return o?t.add(a):t.delete(a),t}),children:[(0,z.jsx)(h,{name:`files`}),(0,z.jsx)(`span`,{className:`tree-name`,title:i.name,children:i.name})]}),o&&(0,z.jsx)(`div`,{role:`group`,children:e.sessions.filter(e=>e.directory===i.id).map(t=>(0,z.jsxs)(v,{className:`tree-item`,role:`treeitem`,"aria-level":2,"aria-selected":r.session===t.id&&r.project===e.project,style:{"--tree-level":2},leading:(0,z.jsx)(`span`,{className:`tree-chevron`,children:(0,z.jsx)(`span`,{className:`assistant-message-dot ${t.unread?`unread`:``}`})}),title:`${t.title} · ${l[t.provider]}`,onClick:()=>ke(e.project,i.id,t.id),children:[(0,z.jsx)(ge,{provider:t.provider}),(0,z.jsx)(`span`,{className:`tree-name`,children:t.title}),t.archived?(0,z.jsx)(`span`,{title:`已归档`,role:`img`,"aria-label":`已归档`,children:(0,z.jsx)(h,{name:`archive`,size:`small`})}):t.state!==`idle`&&(0,z.jsx)(I,{state:t.state,label:Se[t.state]??t.state})]},t.id))})]},i.id)})},e.project))]},e))}),(0,z.jsx)(o,{error:!0,children:G.error})]}),children:[x&&(0,z.jsx)(g,{id:`computer-attach`,title:`接入目录`,onClose:()=>S(!1),children:(0,z.jsxs)(`div`,{className:`stack computer-panel`,children:[(0,z.jsx)(c,{id:`computer-connect`,label:`在目标电脑连接项目`,value:`teammy connect`}),(0,z.jsx)(c,{id:`computer-register`,label:`在该电脑登记执行目录`,value:`teammy agent register --cwd .`}),(0,z.jsx)(`p`,{className:`muted`,children:`完成登记后自动显示。会话可直接在网页使用,也可连接专用群。`})]})}),q?(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(F,{title:Q?(0,z.jsx)(Te,{title:Q.title,busy:f,onSave:e=>Ae(()=>J(`web/local-agent-sessions/${Q.id}/settings`,p,{method:`PUT`,body:{expectedRevision:Q.revision,title:e,config:Q.config}}))},Q.id):(0,z.jsx)(`h2`,{children:q.name}),actions:(0,z.jsxs)(z.Fragment,{children:[K?.capabilities.includes(`local-agent-diff-v1`)&&(0,z.jsx)(s,{icon:`files`,label:`查看工作目录改动`,disabled:!Q||!K.online,onClick:()=>k(!0)}),(0,z.jsx)(s,{icon:`settings`,label:`会话与目录设置`,disabled:!Q,onClick:()=>w(!0)})]})}),D&&Q&&(0,z.jsx)(se,{session:Q.id,request:J,onClose:()=>k(!1)},Q.id),!$&&(0,z.jsx)(o,{children:`升级客户端后可使用多个会话和网页对话。`}),ie&&(0,z.jsx)(g,{id:`computer-new-session`,title:`新建会话`,onClose:()=>R(!1),children:(0,z.jsxs)(`form`,{className:`computer-panel stack`,onSubmit:e=>{e.preventDefault(),Ae(async()=>{let e=await J(`web/local-agents/${q.id}/sessions`,p,{method:`POST`,body:{id:W.current,title:P,provider:B,...B!==`codex`&&V.trim()?{resumeSession:V.trim()}:{}}});W.current=O(),R(!1),re(``),ke(r.project,q.id,e.id)})},children:[(0,z.jsxs)(`label`,{children:[`会话名称`,(0,z.jsx)(`input`,{autoFocus:!0,required:!0,placeholder:`会话名称`,value:P,onChange:e=>re(e.target.value)})]}),(0,z.jsxs)(`label`,{children:[`Agent`,(0,z.jsxs)(`select`,{"aria-label":`Agent`,value:B,onChange:e=>le(e.target.value),children:[(0,z.jsx)(`option`,{value:`codex`,children:`Codex`}),(0,z.jsx)(`option`,{value:`claude`,disabled:!K?.capabilities.includes(`local-agent-providers-v1`),children:`Claude Code`}),(0,z.jsx)(`option`,{value:`cursor`,disabled:!K?.providers.some(e=>e.id===`cursor`),children:`Cursor`}),(0,z.jsx)(`option`,{value:`opencode`,disabled:!K?.providers.some(e=>e.id===`opencode`),children:`OpenCode`}),(0,z.jsx)(`option`,{value:`pi`,disabled:!K?.providers.some(e=>e.id===`pi`),children:`Pi`})]})]}),B!==`codex`&&(0,z.jsxs)(z.Fragment,{children:[K?.providers.find(e=>e.id===B)?.error&&(0,z.jsx)(o,{children:K.providers.find(e=>e.id===B).error}),(0,z.jsxs)(`details`,{children:[(0,z.jsxs)(`summary`,{children:[`继续已有 `,B===`claude`?`Claude`:l[B],` `,`会话`]}),(0,z.jsxs)(`label`,{children:[`原生会话 ID(可选)`,(0,z.jsx)(`input`,{value:V,onChange:e=>fe(e.target.value),placeholder:`留空创建新会话`})]}),(0,z.jsx)(`small`,{className:`muted`,children:`仅继续此目录中已停止的会话,请先退出原终端会话。`})]})]}),(0,z.jsx)(o,{error:!0,children:u}),(0,z.jsx)(`button`,{disabled:f||!P.trim(),children:`创建`})]})}),C&&Q&&K&&(0,z.jsx)(g,{id:`computer-settings`,title:`会话与目录设置`,onClose:()=>w(!1),children:(0,z.jsx)(we,{session:Q,directory:q,entry:K,request:J,busy:f,save:Ae,code:pe,setCode:me},`${Q.id}:${Q.revision}`)}),(0,z.jsxs)(te,{ref:H,onScroll:e=>{let t=e.currentTarget;_e.current=t.scrollHeight-t.scrollTop-t.clientHeight<96},"aria-label":`本地会话记录`,children:[(0,z.jsx)(he,{messages:Z?.messages??[],imageUrl:e=>ce(r.project,Q.id,e),renderQueue:e=>(0,z.jsx)(de,{message:e,session:Q.id,request:J,refresh:X.reload}),renderQuestion:e=>(0,z.jsx)(ve,{question:e,session:Q.id,request:J,refresh:X.reload})}),!Z?.messages.length&&(0,z.jsx)(`div`,{className:`assistant-empty`,children:`在当前目录开始一段对话。`})]}),Z?.commands.filter(e=>e.state!==`succeeded`&&e.kind!==`diff`).slice(-3).map(e=>(0,z.jsxs)(`p`,{className:`computer-control-status`,role:`status`,children:[e.kind,` · `,Se[e.state]??e.state,e.error?`:${e.error}`:``]},e.id)),(0,z.jsx)(o,{error:!0,children:u||X.error||Q?.error}),Q&&(0,z.jsx)(ae,{value:M,onChange:N,label:`向本地 Agent 发送消息`,sendLabel:K?.capabilities.includes(`local-agent-queue-v1`)&&[`working`,`waiting`].includes(Q.state)?`加入队列`:`发送`,placeholder:Q.archived?`会话已归档`:`输入消息…`,disabled:Q.archived||!$,sendDisabled:f||Y.busy||Y.images.length>0&&!Ie,attachments:(0,z.jsxs)(z.Fragment,{children:[Y.preview(f),Y.images.length>0&&!Ie&&(0,z.jsx)(o,{children:`当前模型不支持图片,请切换模型或移除图片。`})]}),hasAttachments:Y.images.length>0,onFiles:Ie&&!f?e=>void Y.add(e):void 0,actions:(0,z.jsxs)(z.Fragment,{children:[Ie&&Y.picker(f||!$),(0,z.jsx)(ye,{session:Q,models:Fe,busy:f,available:!!$,online:!!K?.online,commands:Pe,controls:Ne?.controls,draft:M,onInsert:e=>{Me(e.kind===`skill`?e:null),N(`${e.prefix??(e.kind===`skill`?`$`:`/`)}${e.name} `),requestAnimationFrame(()=>document.querySelector(`.message-composer textarea`)?.focus())},onConfig:e=>{w(!1),Ae(()=>J(`web/local-agent-sessions/${Q.id}/settings`,p,{method:`PUT`,body:{expectedRevision:Q.revision,title:Q.title,config:e}}))}})]}),onSubmit:e=>{e.preventDefault();let t=M.trim();if(!t&&!Y.images.length)return;let n=Y.images.map(e=>e.id),r=je?.path&&t.startsWith(`$${je.name}`)?[{name:je.name,path:je.path}]:void 0,i=JSON.stringify({session:Q.id,body:t,skills:r,images:n});U.current?.fingerprint!==i&&(U.current={fingerprint:i,id:O()});let a=U.current;Ae(async()=>{await J(`web/local-agent-sessions/${Q.id}/messages`,ee(),{method:`POST`,body:{id:a.id,body:t,...n.length?{images:n}:{},...r?{skills:r}:{}}}),N(e=>e.trim()===t?``:e),Me(null),Y.clear(),U.current===a&&(U.current=void 0)})}})]}):(0,z.jsxs)(`div`,{className:`assistant-empty`,children:[`尚未登记本地执行目录。`,(0,z.jsx)(`button`,{onClick:()=>S(!0),children:`接入目录`})]})]})}function K({value:e,onChange:t,models:n,provider:r=`codex`,controls:i}){let a=n.find(t=>t.id===e.model);return(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(`label`,{children:[`模型`,(0,z.jsxs)(`select`,{value:e.model??``,onChange:n=>t({...e,model:n.target.value||null,effort:null,...r===`cursor`?{options:{}}:{}}),children:[(0,z.jsx)(`option`,{value:``,children:`本机默认`}),n.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,z.jsxs)(`label`,{children:[a?.effortLabel??`思考强度`,(0,z.jsxs)(`select`,{value:e.effort??``,onChange:n=>t({...e,effort:n.target.value||null}),children:[(0,z.jsx)(`option`,{value:``,children:`模型默认`}),a?.efforts.map(e=>(0,z.jsx)(`option`,{children:e},e))]})]}),(i??S(r)).map(n=>(0,z.jsxs)(`label`,{children:[n.label,(0,z.jsx)(`select`,{value:e[n.key]??n.defaultValue,onChange:r=>t(n.key===`mode`?{...e,mode:r.target.value||void 0}:{...e,permission:r.target.value}),children:n.choices.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]},n.key)),r===`pi`&&(0,z.jsx)(`small`,{className:`muted`,children:`遵循 Pi 原生工具和扩展权限;扩展问答仍需确认。`}),a?.options?.map(n=>(0,z.jsxs)(`label`,{children:[n.name,(0,z.jsxs)(`select`,{value:e.options?.[n.id]??``,onChange:r=>{let i={...e.options};r.target.value?i[n.id]=r.target.value:delete i[n.id],t({...e,options:i})},children:[(0,z.jsx)(`option`,{value:``,children:`模型默认`}),n.choices.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]},n.id))]})}function we({session:e,directory:r,entry:i,request:o,busy:s,save:l,code:u,setCode:d}){let{projectId:f}=j(),[m,h]=(0,L.useState)(r.defaults??t.parse({})),[g,_]=(0,L.useState)(r.defaultSession??e.id),[v,y]=(0,L.useState)(r.name),[b,x]=(0,L.useState)(r.responsibilities),[S,C]=(0,L.useState)(r.enabled),[w,T]=(0,L.useState)(e.executionDirectory),[E,D]=(0,L.useState)();return(0,L.useEffect)(()=>{o(`web/local-agent-settings`,n).then(D).catch(()=>{})},[o]),(0,z.jsxs)(`div`,{className:`computer-panel stack`,children:[(0,z.jsxs)(`details`,{open:!0,children:[(0,z.jsx)(`summary`,{children:`执行位置与连接`}),(0,z.jsx)(`div`,{className:`config-fields`,children:(0,z.jsxs)(`label`,{children:[`执行位置`,(0,z.jsxs)(`select`,{value:w??``,onChange:e=>T(e.target.value||null),children:[(0,z.jsx)(`option`,{value:``,children:`原登记目录`}),i.directories.filter(e=>e.id!==r.id).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]})}),e.cwd&&(0,z.jsxs)(`p`,{className:`computer-paths`,children:[`当前执行路径:`,(0,z.jsx)(`code`,{children:e.cwd})]}),(0,z.jsx)(`button`,{disabled:s,onClick:()=>void l(()=>o(`web/local-agent-sessions/${e.id}/settings`,p,{method:`PUT`,body:{expectedRevision:e.revision,title:e.title,config:e.config,executionDirectory:w}})),children:`保存执行位置`}),(0,z.jsx)(`button`,{disabled:s||e.bound,onClick:()=>void l(async()=>{d((await o(`web/local-agent-bindings/codes`,k({code:M()}),{method:`POST`,body:{directory:r.id,session:e.id,expectedRevision:e.bindingRevision}})).code)}),children:e.bound?`已连接专用群`:`连接专用群`}),u&&(0,z.jsx)(c,{id:`session-binding`,label:`在目标群发送`,value:`/bind ${u}`})]}),(0,z.jsxs)(`details`,{children:[(0,z.jsx)(`summary`,{children:`目录设置与工作转交`}),(0,z.jsxs)(`div`,{className:`config-fields`,children:[(0,z.jsxs)(`label`,{children:[`目录名称`,(0,z.jsx)(`input`,{value:v,onChange:e=>y(e.target.value)})]}),(0,z.jsxs)(`label`,{children:[`职责`,(0,z.jsx)(`textarea`,{value:b,onChange:e=>x(e.target.value)})]}),(0,z.jsxs)(`label`,{children:[`默认会话`,(0,z.jsx)(`select`,{value:g,onChange:e=>_(e.target.value),children:i.sessions.filter(e=>e.directory===r.id&&!e.archived).map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.title},e.id))})]}),(0,z.jsx)(K,{value:m,onChange:h,provider:r.provider,controls:i.catalogs.find(e=>e.directory===r.id&&e.provider===r.provider)?.controls,models:i.providers.find(e=>e.id===r.provider)?.models??i.models})]}),(0,z.jsx)(`p`,{className:`muted`,children:`用于新会话与新派工。`}),(0,z.jsxs)(`label`,{className:`check-label`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:S,disabled:s,onChange:e=>C(e.target.checked)}),`允许 Tim 转交工作`]}),(0,z.jsx)(`button`,{disabled:s,onClick:()=>void l(()=>o(`web/local-agents/${r.id}/settings`,ee(),{method:`PUT`,body:{defaultSession:g,defaults:m,name:v,responsibilities:b,enabled:S,expectedRevision:r.revision}})),children:`保存目录默认设置`}),(0,z.jsx)(`p`,{children:r.available?`可接收 Tim 转交的工作`:r.reason}),E&&!E.enabled&&(0,z.jsxs)(`p`,{className:`muted`,children:[`项目尚未允许转交,请在`,(0,z.jsx)(`a`,{href:a(`/projects/${f}/settings?tab=connect`),children:`项目设置`}),`中开启。`]}),(0,z.jsx)(c,{id:`directory-intake`,label:r.enabled?`暂停 Tim 向此目录转交`:`允许 Tim 向此目录转交`,value:`teammy agent ${r.enabled?`disable`:`enable`} --id ${r.id}`})]})]})}function Te({title:e,busy:t,onSave:n}){let[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(e);return r?(0,z.jsx)(`form`,{className:`session-title-form`,onSubmit:t=>{t.preventDefault(),a.trim()&&a.trim()!==e&&n(a.trim()),i(!1)},children:(0,z.jsx)(`input`,{autoFocus:!0,"aria-label":`会话标题`,value:a,disabled:t,onChange:e=>o(e.target.value),onBlur:()=>i(!1),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),i(!1))}})}):(0,z.jsx)(`h2`,{children:(0,z.jsx)(`button`,{type:`button`,className:`session-rename`,title:`重命名会话`,"aria-label":`重命名会话:${e}`,onClick:()=>{o(e),i(!0)},children:e})})}export{Ce as Computers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#workspace-diff{width:min(900px,100vw - 32px);max-width:calc(100vw - 32px)}.workspace-diff{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.workspace-diff p{margin:0}.workspace-diff-toolbar,.workspace-diff summary{justify-content:space-between;align-items:center;gap:16px;display:flex}.workspace-diff summary{cursor:pointer;padding:10px 0;font-size:13px}.workspace-diff summary span,.workspace-diff-path{overflow-wrap:anywhere}.workspace-diff summary small{white-space:nowrap;color:var(--color-muted)}.workspace-diff pre{background:var(--color-surface);border:1px solid var(--color-line);border-radius:6px;max-height:50vh;margin:0;padding:10px;font-size:12px;line-height:1.6;overflow:auto}.workspace-diff pre span{min-width:100%;display:block}.diff-added{color:#247944;background:#2a91531f}.diff-removed{color:#ac3434;background:#be3a3a1a}.diff-hunk{color:#566e9a}.session-images{flex-wrap:wrap;gap:8px;padding:6px 0;display:flex}.session-image{position:relative}.session-image img{object-fit:cover;border:1px solid var(--color-line);border-radius:8px;width:112px;height:88px;display:block}.session-image button{background:var(--color-surface);border-radius:50%;width:24px;height:24px;padding:3px;position:absolute;top:4px;right:4px}.session-image-file{display:none}.queued-message{flex-wrap:wrap;align-items:center;gap:8px;margin-top:5px;display:flex}.queued-message-actions{gap:8px;display:flex}.queued-message-actions button{min-height:26px;padding:2px 8px;font-size:12px}.queued-message-editor{gap:8px;width:100%;display:grid}.queued-message-editor textarea{resize:vertical;width:100%;min-height:80px}.computer-messages{width:100%;max-width:820px;margin:0 auto}.computer-agent-message{overflow-wrap:anywhere;min-width:0;margin:24px 0}.computer-agent-message .markdown{font-size:var(--text-base);line-height:1.8}.computer-agent-message .markdown>:first-child{margin-top:0}.computer-agent-message .markdown>:last-child{margin-bottom:0}.computer-agent-message .markdown :is(h1,h2){font-size:18px}.computer-agent-message .markdown :is(h3,h4,h5,h6){font-size:var(--text-base)}.computer-agent-message .markdown pre{max-width:100%;overflow-x:auto}.computer-commentary{margin:20px 0}.computer-divider{color:var(--color-muted);font-size:var(--text-xs);text-align:center;align-items:center;gap:14px;margin:28px 0;line-height:1.6;display:flex}.computer-divider:before,.computer-divider:after{content:"";border-top:1px solid var(--color-line);flex:1;min-width:16px}.computer-divider>span{overflow-wrap:anywhere;max-width:80%}.computer-tool{min-width:0;color:var(--color-muted);font-size:var(--text-sm);margin:10px 0}.computer-tool>summary{cursor:pointer;align-items:center;gap:8px;min-height:32px;padding:6px 0;list-style:none;display:flex}.computer-tool>summary::-webkit-details-marker{display:none}.computer-tool>summary>.icon{flex-shrink:0;width:12px;height:12px}.computer-tool[open]>summary>.icon{transform:rotate(90deg)}.computer-tool-label{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.computer-tool-status{font-size:var(--text-xs);flex-shrink:0;gap:6px;display:flex}.computer-tool pre{border-left:1px solid var(--color-line);background:var(--color-soft);border-radius:0 var(--radius-sm) var(--radius-sm) 0;white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;font-size:var(--text-xs);margin:4px 0 14px 20px;padding:12px 16px;line-height:1.65;overflow:auto}.agent-logo{object-fit:contain;flex-shrink:0;width:24px;height:24px;padding:1px;display:block}.inline-reply{width:clamp(180px, var(--reply-width,180px), 600px);border:1px solid var(--color-line);border-radius:var(--radius-sm);background:0 0;align-items:flex-end;gap:4px;max-width:100%;padding:3px 6px;display:flex}.inline-reply:focus-within{border-color:var(--color-muted)}.inline-reply textarea{width:100%;min-width:0;min-height:28px;max-height:180px;font-size:var(--text-sm);resize:none;box-shadow:none;background:0 0;border:0;padding:3px 2px;line-height:22px}.inline-reply textarea:focus{box-shadow:none;outline:none}.inline-reply-send{background:0 0;border:0;flex:0 0 26px;place-items:center;width:26px;height:28px;min-height:28px;padding:3px;display:grid}.native-question{grid-template-columns:minmax(0,1fr);gap:12px;min-width:0;display:grid}.native-question>*{min-width:0}.native-question-part{grid-template-columns:minmax(0,1fr);justify-items:start;gap:8px;min-width:0;display:grid}.native-question-part>p{color:var(--color-text);font-size:var(--text-base);margin:0}.question-options,.question-actions{flex-wrap:wrap;align-items:stretch;gap:8px;max-width:100%;display:flex}.question-options button,.question-actions>button{min-height:var(--control-height);margin:0;line-height:20px}.question-options button{text-align:left;min-width:0;max-width:100%;font-size:var(--text-sm);flex-direction:column;flex-shrink:1;justify-content:center;align-items:flex-start;gap:4px;padding:10px 12px;font-weight:500;display:flex}.question-options button[aria-pressed=true]{border-color:var(--brand-orange);background:var(--color-accent-soft);color:var(--color-link)}.question-options button small{color:var(--color-muted);font-size:var(--text-xs);white-space:normal;font-weight:400;line-height:1.6}.question-options-described{grid-template-columns:repeat(auto-fit,minmax(min(100%,180px),1fr));width:100%;display:grid}.question-options-described button{justify-content:flex-start}.question-option-label{align-items:center;gap:8px;display:flex}.question-check{border:1px solid;border-radius:3px;flex:0 0 14px;justify-content:center;align-items:center;width:14px;height:14px;display:inline-flex}.question-check .icon{width:12px;height:12px}.question-response,.question-result{align-items:baseline;gap:6px;display:flex}.question-response span{white-space:pre-wrap;overflow-wrap:anywhere}.question-result{color:var(--color-muted);font-size:var(--text-xs)}.question-response .icon,.question-result .icon{width:12px;height:12px;color:var(--color-muted);flex-shrink:0}.native-approval-detail{white-space:pre-wrap;overflow-wrap:anywhere;max-height:320px;overflow:auto}.native-approval-options{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,216px);display:grid}.native-approval-options button{text-align:center;align-items:center}.native-plan{border:1px solid var(--color-line);border-radius:12px;gap:16px;padding:18px 20px}.native-plan-heading{color:var(--color-muted);font-size:var(--text-sm);align-items:center;gap:8px;display:flex}.native-plan-content{overscroll-behavior:contain;scrollbar-width:thin;min-height:0;max-height:min(480px,50dvh);overflow:auto}.native-plan .markdown :is(h1,h2){font-size:var(--text-lg);margin:18px 0 10px}.native-plan .markdown>:first-child{margin-top:0}.native-plan-history summary{cursor:pointer;color:var(--color-muted)}.native-plan-history[open] summary{margin-bottom:16px}.native-plan-actions{grid-template-columns:repeat(3,minmax(0,1fr));grid-auto-rows:1fr;width:min(100%,360px);display:grid}.native-plan-actions-expanded{grid-template-columns:repeat(2,minmax(0,1fr))}.native-plan-actions>button{min-width:0;padding:10px 8px}.native-plan-note{font-size:var(--text-xs);margin-top:-8px;line-height:1.6}.native-plan-feedback{gap:10px;display:grid}.native-plan-feedback label{font-size:var(--text-sm);gap:6px;display:grid}.native-plan-feedback textarea{width:100%;min-height:96px;font-size:var(--text-base)}.native-plan-feedback-actions{grid-template-columns:repeat(2,minmax(0,1fr));width:min(100%,280px);display:grid}.native-plan-feedback-actions>button{min-width:0;padding:10px 8px}@media (width<=600px){.native-plan{padding:12px}.native-plan-content{max-height:240px}}.composer-menu .dropdown-trigger{height:30px;min-height:30px;font-size:var(--text-xs);color:var(--color-muted);background:var(--color-soft);border-radius:18px;align-items:center;gap:4px;max-width:min(190px,100%);padding:5px 9px;display:flex}.composer-menu .dropdown-trigger>span{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.composer-menu .dropdown-trigger:hover,.composer-menu .dropdown-trigger[aria-expanded=true]{color:var(--color-text);background:var(--color-hover)}.composer-commands .dropdown-trigger{background:var(--color-soft);border-radius:50%;justify-content:center;width:30px;padding:6px}.composer-menu .dropdown-menu{--dropdown-max-height:45dvh;width:300px;max-width:calc(100vw - var(--sidebar-width) - 32px);max-height:45dvh;top:auto;bottom:calc(100% + 12px)}.composer-menu .dropdown-menu [role=menuitem]{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:10px}.composer-option-copy{text-align:left;flex-direction:column;gap:3px;min-width:0;display:flex}.composer-option-copy small,.composer-menu-heading small{font-size:var(--text-xs);color:var(--color-muted);font-weight:400}.composer-menu code{color:var(--color-muted);background:0 0;font-size:11px}.composer-menu-heading{font-size:var(--text-sm);justify-content:space-between;gap:12px;padding:8px 10px;display:flex}@media (width<=600px){.composer-menu .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px);max-width:none}.composer-menu .dropdown-trigger{max-width:min(140px,100%)}}.composer-choice{flex:0 auto;min-width:0}.composer-commands{flex-shrink:0}.composer-commands .icon{width:17px;height:17px}.composer-commands .dropdown-menu{width:640px}.composer-commands .dropdown-menu [role=menuitem]{padding:8px 10px}.composer-command-row{align-items:center;gap:20px;width:100%;min-width:0;display:flex}.composer-command-name{flex:0 190px;min-width:0}.composer-command-row small{min-width:0;color:var(--color-muted);font-weight:400;font-size:var(--text-xs);flex:1}.composer-command-row>*{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}@media (width<=600px){.composer-commands .dropdown-menu{width:calc(100vw - var(--sidebar-width) - 16px)}.composer-command-name{flex-basis:42%}.composer-command-row{gap:10px}}.composer-option-copy small{text-overflow:ellipsis;white-space:nowrap;max-width:260px;overflow:hidden}@media (width<=600px){.computers-layout .message-composer-actions{flex-wrap:wrap;row-gap:8px}.computers-layout .message-composer-footer{align-items:flex-end}}.computer-panel{border-bottom:1px solid var(--color-line);max-height:55vh;padding:16px 24px;overflow:auto}.config-fields{grid-template-columns:repeat(auto-fit,minmax(160px,1fr));gap:12px;padding:12px 0;display:grid}.config-fields label{flex-direction:column;gap:6px;display:flex}.computer-control-status{margin:0;padding:4px 24px;font-size:12px}@media (width<=760px){.computer-panel{padding:12px}}.computer-tree{padding:4px}.computer-device{font-size:var(--text-sm);align-items:center;gap:8px;margin:0 0 14px;font-weight:600;display:flex}.computer-device>span{text-overflow:ellipsis;white-space:nowrap;overflow:hidden}.computer-connection{flex-shrink:0;display:inline-flex}.computer-connection.online .icon rect{fill:var(--brand-orange);fill-opacity:.85}.computer-paths{color:var(--color-muted);font-size:var(--text-xs);overflow-wrap:anywhere;margin:8px 0;display:block}.computer-tree .tree-name{flex:1}.computer-panel{flex-shrink:0}.computers-layout dialog .computer-panel{border:0;max-height:70dvh;padding:0}.computer-create-menu .dropdown-trigger{place-items:center;width:32px;height:32px;padding:4px;display:grid}.computer-create-menu .dropdown-menu{width:180px;left:auto;right:0}.session-rename{font:inherit;font-weight:inherit;text-align:left;text-overflow:ellipsis;white-space:nowrap;background:0 0;border:0;border-radius:0;max-width:100%;padding:0;overflow:hidden}.session-rename:hover{color:var(--color-muted);background:0 0}.session-title-form{flex:1;min-width:0;margin-right:16px}.session-title-form input{width:100%}.computers-layout .message-composer{align-self:center;width:calc(100% - 56px);max-width:844px}@media (width<=900px){.computers-layout .message-composer{width:calc(100% - 32px)}}@media (width<=600px){.computers-layout .message-composer{width:calc(100% - 16px)}}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{$ as e,h as t}from"./index-DiR0ePCJ.js";var n=e();function r({navigation:e,children:r,className:i=``,tree:a=!1,label:o,testId:s}){return(0,n.jsx)(t,{className:`assistant-layout conversation-layout ${i}`,"data-testid":s,navigation:(0,n.jsx)(`aside`,{className:`assistant-list ${a?`file-tree-pane`:``}`,"aria-label":`${o}列表`,children:e}),children:(0,n.jsx)(`section`,{className:`assistant-thread`,"aria-label":o,children:r})})}function i({mine:e=!1,author:t,time:r,children:i,className:a=``,ref:o,...s}){return(0,n.jsx)(`div`,{...s,ref:o,className:`assistant-bubble-row ${e?`mine`:``} ${a}`,children:(0,n.jsxs)(`div`,{className:`assistant-bubble`,children:[(0,n.jsxs)(`div`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`span`,{children:t}),r&&(0,n.jsx)(`time`,{dateTime:r,children:new Date(r).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})})]}),i]})})}function a({label:e,state:t=`idle`}){return(0,n.jsx)(`span`,{className:`conversation-status state-${t}`,role:`img`,"aria-label":e,title:e})}function o({author:e,time:t,children:r}){return(0,n.jsxs)(`article`,{className:`conversation-post assistant-bubble`,children:[(0,n.jsxs)(`header`,{className:`assistant-bubble-meta`,children:[(0,n.jsx)(`strong`,{children:e}),t&&(0,n.jsx)(`time`,{dateTime:t,children:new Date(t).toLocaleString(`zh-CN`,{month:`numeric`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})})]}),r]})}function s({title:e,actions:t}){return(0,n.jsxs)(`header`,{className:`assistant-thread-heading`,children:[(0,n.jsx)(`div`,{className:`conversation-title`,children:e}),t]})}function c({ref:e,...t}){return(0,n.jsx)(`div`,{role:`log`,"aria-live":`polite`,...t,ref:e,className:`assistant-transcript`})}export{c as a,o as i,s as n,a as o,r,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.task-board{min-width:0}.task-board .page-header{flex-wrap:wrap;align-items:flex-start;margin-bottom:24px}.task-board .page-header>div{min-width:0}.task-board .page-header h1,.task-board .page-header p{overflow-wrap:anywhere}.task-board-toolbar{flex-wrap:wrap;align-items:center;gap:8px;margin-bottom:24px;display:flex}.task-board-lanes{grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));align-items:start;gap:24px;margin-bottom:32px;display:grid}.task-lane{min-width:0}.task-lane h2{font-size:var(--text-base);border-bottom:1px solid var(--color-line);align-items:center;gap:10px;padding:0 0 16px;font-weight:600;display:flex}.task-lane .count{margin-left:auto}.task-lane-content{flex-direction:column;gap:12px;padding-top:16px;display:flex}.lane-dot{border:1.5px solid var(--color-muted);border-radius:50%;width:8px;height:8px}.task-lane[data-stage=in_progress] .lane-dot{border-color:var(--brand-orange);background:var(--brand-orange)}.task-lane[data-stage=in_review] .lane-dot{border-color:var(--brand-black);background:var(--brand-black)}.task-lane[data-stage=completed] .lane-dot{border-color:var(--color-muted);background:var(--color-muted)}.task-lane-empty{font-size:var(--text-xs);color:var(--color-muted);padding:44px 0}.task-card{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);overflow-wrap:anywhere;min-width:0;position:relative}.task-card>.task-card-heading{border-radius:inherit;padding:16px;list-style:none;position:static}.task-age{white-space:nowrap;color:var(--color-muted);font-size:var(--text-xs);flex-shrink:0;align-items:center;gap:4px;margin-left:auto;font-weight:400;display:inline-flex}.task-age .icon{width:13px;height:13px}.task-age.stale{color:var(--brand-orange)}.task-lane-expand{min-height:32px;color:var(--color-muted);font-size:var(--text-xs);background:0 0;border:0;justify-content:center;align-items:center;gap:6px;display:flex}.task-card-heading::-webkit-details-marker{display:none}.task-card-heading:hover{background:var(--color-soft)}.task-card[open]>.task-card-heading h3{padding-right:32px}.task-card-meta{align-items:center;gap:8px;margin-top:8px;display:flex}.task-card-meta>small{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.task-confirmation{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:var(--brand-orange);font-size:calc(var(--text-xs) - 1px);flex-shrink:0;align-items:center;gap:3px;padding:0 4px;font-weight:400;line-height:18px;display:inline-flex}.task-confirmation .icon{width:12px;height:12px}.task-card-confirm{flex-direction:column;align-items:flex-end;gap:8px;margin-top:16px;display:flex}.task-card-confirm button{min-height:32px;font-size:var(--text-xs);padding:4px 12px}.task-status-field legend{font-size:var(--text-sm);margin-bottom:8px;font-weight:600}.task-status-options{grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;display:grid}.task-status-choice{cursor:pointer;position:relative}.task-status-choice input{opacity:0;width:100%;height:100%;min-height:0;cursor:inherit;position:absolute;inset:0}.task-status-choice span{border:1px solid var(--color-line);border-radius:var(--radius-md);background:var(--color-surface);min-height:36px;font-size:var(--text-sm);justify-content:center;align-items:center;font-weight:550;display:flex}.task-status-choice:hover span{background:var(--color-soft)}.task-status-choice input:checked+span{border-color:var(--brand-black);background:var(--brand-black);color:var(--color-on-dark)}.task-status-choice input:focus-visible+span{outline:2px solid var(--brand-orange);outline-offset:3px}.task-status-choice input:disabled+span{opacity:.45;cursor:default}.task-card-heading h3{font-size:var(--text-base);font-weight:650;line-height:1.55}.task-card-edit{opacity:0;pointer-events:none;position:absolute;top:10px;right:8px}.task-card[open]:hover>.task-card-edit{opacity:1;pointer-events:auto}.task-card[open]:has(:focus-visible)>.task-card-edit{opacity:1;pointer-events:auto}.task-progress{font-size:var(--text-sm);white-space:pre-wrap;line-height:1.85}.task-card small{color:var(--color-muted);font-size:var(--text-xs)}.task-card-details{padding:0 16px 16px}.task-card-details h4{font-size:var(--text-xs);margin:16px 0 4px;font-weight:600}.task-card-details p{font-size:var(--text-sm);margin:0}.task-card-sources{flex-direction:column;align-items:flex-start;gap:8px;margin:16px 0;display:flex}.task-card-sources a{text-align:left;overflow-wrap:anywhere;max-width:100%;font-size:var(--text-xs);min-height:28px;color:var(--color-muted);justify-content:flex-start;gap:8px;padding:4px 0;text-decoration:none;display:inline-flex}.task-card-sources a:hover{color:var(--color-link);text-decoration:underline}.task-mention{border-radius:var(--radius-sm);background:var(--color-accent-soft);color:inherit;padding:0 2px}button.pill-control,.pill-menu .dropdown-trigger{background:var(--color-soft);min-height:30px;color:var(--color-muted);font-size:var(--text-xs);white-space:nowrap;border:1px solid #0000;border-radius:999px;justify-content:center;align-items:center;gap:6px;padding:5px 11px;font-weight:500;line-height:18px;display:inline-flex}button.pill-control:hover,button.pill-control[aria-pressed=true],.pill-menu .dropdown-trigger:hover,.pill-menu .dropdown-trigger[aria-expanded=true]{background:var(--color-hover);color:var(--color-text)}button.pill-control[aria-pressed=true]{border-color:var(--color-line)}.pill-control>.icon,.pill-menu .dropdown-trigger>.icon{flex-shrink:0;width:14px;height:14px}.pill-menu .dropdown-menu{border-radius:var(--radius-md);width:168px;padding:5px;top:calc(100% + 6px)}.pill-menu .dropdown-menu [role=menuitem]{min-height:32px;font-size:var(--text-xs);gap:8px;padding:8px;font-weight:500}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,B as t,Et as n,F as r,G as i,H as a,I as o,J as s,K as c,R as l,Tt as u,V as d,W as f,X as p,Y as m,Z as h,g,nt as _,x as v}from"./index-DiR0ePCJ.js";import{t as y}from"./project-links-Dy6-B89_.js";import"./file-links-DnngiTbC.js";var b=u(),x=e();function S({className:e=``,...t}){return(0,x.jsx)(`button`,{type:`button`,...t,className:`pill-control ${e}`})}function C({className:e=``,...t}){return(0,x.jsx)(g,{...t,className:`pill-menu ${e}`})}var w=[{value:`time`,label:`按时间`,icon:`clock`},{value:`owner`,label:`按用户`,icon:`members`}],T=[{status:`planned`,label:`计划`},{status:`in_progress`,label:`进行中`},{status:`in_review`,label:`待验收`},{status:`completed`,label:`已完成`},{status:null,label:`未明确`}];function E({members:e,project:t,userName:a,memberId:o}){let{request:s,projectId:u}=v(),f=`teammy-board-mine:${o}:${u}`,[m,g]=(0,b.useState)(()=>{try{return localStorage.getItem(f)===`true`}catch{return!1}}),_=`teammy-board-order:${o}:${u}`,[y,E]=(0,b.useState)(()=>{try{return localStorage.getItem(_)===`owner`?`owner`:`time`}catch{return`time`}}),O=w.find(e=>e.value===y),k=(0,b.useCallback)(e=>s(`tasks`,r,{signal:e}),[s]),j=p(k,3e3,h(u,`tasks`)),[M,N]=(0,b.useState)(),[P,F]=(0,b.useState)(!1),[I,L]=(0,b.useState)(Date.now);(0,b.useEffect)(()=>{let e=setInterval(()=>L(Date.now()),6e4);return()=>clearInterval(e)},[]);let R=j.data,z=R?.tasks.filter(e=>!m||e.owner===o)??[],B=new Set(e.map(e=>e.id));return(0,x.jsxs)(`div`,{className:`task-board`,children:[(0,x.jsx)(c,{title:t?.projectName.trim()?`${t.projectName.trim()}|工作看板`:`工作看板`,description:t?.description.trim()||``,children:(0,x.jsx)(`a`,{className:`account-home`,"data-testid":`home-link`,href:n(`/projects`),onClick:e=>{e.button||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),history.pushState(null,``,n(`/projects`)),window.dispatchEvent(new PopStateEvent(`popstate`)))},"aria-label":`项目主页`,"data-tooltip":`项目主页`,children:(0,x.jsx)(`strong`,{children:a})})}),(0,x.jsxs)(`div`,{className:`task-board-toolbar`,role:`group`,"aria-label":`看板筛选与排序`,children:[(0,x.jsxs)(S,{"aria-pressed":m,"data-testid":`task-board-mine`,onClick:()=>{let e=!m;g(e),F(!1);try{localStorage.setItem(f,String(e))}catch{}},children:[(0,x.jsx)(d,{name:m?`enable`:`account`,size:`small`}),`只看我的`]}),(0,x.jsx)(C,{id:`task-board-sort-menu`,triggerId:`task-board-sort`,label:`任务排序:${O.label}`,routeKey:y,trigger:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(d,{name:O.icon,size:`small`}),(0,x.jsx)(`span`,{children:O.label}),(0,x.jsx)(d,{name:`chevronDown`,size:`small`})]}),children:e=>w.map(t=>(0,x.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-label":t.label,onClick:()=>{e(),E(t.value),F(!1);try{localStorage.setItem(_,t.value)}catch{}},children:[(0,x.jsx)(d,{name:t.icon,size:`small`}),(0,x.jsx)(`span`,{children:t.label}),y===t.value&&(0,x.jsx)(d,{name:`check`,size:`small`})]},t.value))})]}),(0,x.jsx)(i,{error:!0,children:j.error}),(0,x.jsx)(`section`,{className:`task-board-lanes`,"aria-label":`任务进度`,"data-testid":`progress-board`,children:T.filter(e=>e.status!==null||z.some(e=>e.status===null)).map(e=>{let t=z.filter(t=>t.status===e.status);t.sort((t,n)=>(y===`owner`?t.owner.localeCompare(n.owner,`en`,{numeric:!0}):0)||(e.status===`completed`?n.statusSince.localeCompare(t.statusSince):t.statusSince.localeCompare(n.statusSince))||t.id.localeCompare(n.id));let n=e.status===`completed`&&!P?t.slice(0,5):t;return(0,x.jsxs)(`section`,{className:`task-lane`,"aria-label":e.label,"data-stage":e.status??`unknown`,children:[(0,x.jsxs)(`h2`,{children:[(0,x.jsx)(`span`,{className:`lane-dot`}),e.label,(0,x.jsx)(l,{children:R?t.length:`—`})]}),(0,x.jsxs)(`div`,{className:`task-lane-content`,children:[t.length?n.map(e=>(0,x.jsx)(D,{task:e,memberIds:B,now:I,onEdit:()=>N(e),onSaved:()=>void j.reload()},e.id)):(0,x.jsx)(`p`,{className:`task-lane-empty`,children:j.error&&!R?`读取失败`:R?`暂无任务`:`读取中…`}),e.status===`completed`&&t.length>5&&(0,x.jsxs)(`button`,{type:`button`,className:`task-lane-expand`,"aria-expanded":P,onClick:()=>F(!P),children:[(0,x.jsx)(d,{name:P?`chevronUp`:`chevronDown`,size:`small`}),P?`收起`:`展开其余 ${t.length-5} 项`]})]})]},e.label)})}),M&&(0,x.jsx)(A,{task:M,onClose:()=>N(void 0),onSaved:()=>{N(void 0),j.reload()}},M.id)]})}function D({task:e,memberIds:t,onEdit:r,onSaved:c,now:l}){let{projectId:u,request:f}=v(),p=m(),[h,g]=(0,b.useState)(!1),[S,C]=(0,b.useState)(``);async function w(){if(!h){g(!0),C(``);try{await f(`tasks/${e.id}/correction`,o,{method:`PATCH`,signal:p,body:{needsConfirmation:!1,expectedRevision:e.revision}}),p.aborted||c()}catch(e){p.aborted||C(_(e))}finally{g(!1)}}}return(0,x.jsxs)(`details`,{className:`task-card`,"data-testid":`task-card`,"data-task-id":e.id,"data-owner":e.owner,"data-status":e.status??`unknown`,children:[(0,x.jsxs)(`summary`,{className:`task-card-heading`,"data-testid":`task-toggle`,children:[(0,x.jsx)(`h3`,{children:e.title}),(0,x.jsxs)(`span`,{className:`task-card-meta`,children:[(0,x.jsx)(`small`,{title:e.owner,children:e.owner}),e.needsConfirmation&&(0,x.jsxs)(`span`,{className:`task-confirmation`,"data-testid":`task-confirmation`,children:[(0,x.jsx)(d,{name:`attention`,size:`small`}),`需要确认`]}),e.status!==`completed`&&(0,x.jsx)(O,{since:e.statusSince,now:l})]})]}),(0,x.jsx)(a,{icon:`edit`,className:`task-card-edit`,label:`纠正任务:${e.title}`,"data-testid":`task-correct`,disabled:h,onClick:r}),(0,x.jsxs)(`div`,{className:`task-card-details`,children:[(0,x.jsx)(`h4`,{children:`目标`}),(0,x.jsx)(`p`,{children:e.goal?(0,x.jsx)(k,{value:e.goal,memberIds:t}):`目标未明确`}),(0,x.jsx)(`h4`,{children:`当前进展`}),(0,x.jsx)(`p`,{className:`task-progress`,children:(0,x.jsx)(k,{value:e.progress,memberIds:t})}),(0,x.jsx)(`div`,{className:`task-card-sources`,children:e.sources.map(t=>(0,x.jsxs)(`a`,{"data-testid":`task-source`,href:n(t.kind===`material`?`/projects/${u}/materials?id=${t.materialId}&revision=${t.revision}`:y(u,e.owner,t.path)),children:[(0,x.jsx)(d,{name:`file`,size:`small`}),(0,x.jsx)(`span`,{children:t.path})]},t.path))}),e.syncedAt&&(0,x.jsxs)(`small`,{children:[`资料同步于 `,(0,x.jsx)(s,{value:e.syncedAt})]}),e.needsConfirmation&&(0,x.jsxs)(`div`,{className:`task-card-confirm`,children:[(0,x.jsx)(i,{error:!0,children:S}),(0,x.jsx)(`button`,{className:`primary`,"data-testid":`task-confirm-save`,disabled:h,onClick:()=>void w(),children:h?`正在保存…`:`保存`})]})]})]})}function O({since:e,now:t}){let n=Math.max(0,t-Date.parse(e)),r=Math.floor(n/6e4),i=r<1?`刚刚`:r<60?`${r} 分钟`:r<1440?`${Math.floor(r/60)} 小时`:`${Math.floor(r/1440)} 天`;return(0,x.jsxs)(`span`,{className:`task-age${n>6048e5?` stale`:``}`,"data-testid":`task-age`,title:`进入当前状态:${new Date(e).toLocaleString(`zh-CN`)}`,"aria-label":`当前状态停留 ${i}`,children:[(0,x.jsx)(d,{name:`clock`,size:`small`}),i]})}function k({value:e,memberIds:t}){return e.split(/(@[a-z][a-z0-9_-]*)/gi).map((e,n)=>e.startsWith(`@`)&&t.has(e.slice(1))?(0,x.jsx)(`mark`,{className:`task-mention`,children:e},n):e)}function A({task:e,onClose:n,onSaved:r}){let{request:a}=v(),s=m(),[c,l]=(0,b.useState)(e.title),[u,d]=(0,b.useState)(e.status??``),[p,h]=(0,b.useState)(e.goal??``),[g,y]=(0,b.useState)(e.progress),[S,C]=(0,b.useState)(!1),[w,E]=(0,b.useState)(``),D={...c===e.title?{}:{title:c},...u===(e.status??``)?{}:{status:u||null},...p===(e.goal??``)?{}:{goal:p||null},...g===e.progress?{}:{progress:g},...e.needsConfirmation?{needsConfirmation:!1}:{}};async function O(){if(!S&&Object.keys(D).length){C(!0),E(``);try{await a(`tasks/${e.id}/correction`,o,{method:`PATCH`,signal:s,body:{...D,expectedRevision:e.revision}}),s.aborted||r()}catch(e){s.aborted||E(_(e))}finally{C(!1)}}}return(0,x.jsx)(f,{id:`task-correction`,title:`纠正任务`,onClose:n,children:(0,x.jsxs)(`form`,{className:`stack`,"aria-busy":S,onSubmit:e=>{e.preventDefault(),O()},children:[(0,x.jsx)(t,{id:`task-title`,label:`标题`,children:(0,x.jsx)(`input`,{value:c,required:!0,onChange:e=>l(e.target.value)})}),(0,x.jsxs)(`fieldset`,{className:`task-status-field`,disabled:S,children:[(0,x.jsx)(`legend`,{children:`状态`}),(0,x.jsx)(`div`,{className:`task-status-options`,"data-testid":`task-status`,children:T.filter(e=>e.status!==null).map(e=>(0,x.jsxs)(`label`,{className:`task-status-choice`,children:[(0,x.jsx)(`input`,{type:`radio`,name:`task-status`,value:e.status,checked:u===e.status,onChange:()=>d(e.status)}),(0,x.jsx)(`span`,{children:e.label})]},e.status))}),(0,x.jsx)(`small`,{children:`待验收:任务成果已提交,等待验收或最终确认。`})]}),(0,x.jsx)(t,{id:`task-goal`,label:`目标`,children:(0,x.jsx)(`textarea`,{value:p,onChange:e=>h(e.target.value)})}),(0,x.jsx)(t,{id:`task-progress`,label:`当前进展`,children:(0,x.jsx)(`textarea`,{value:g,onChange:e=>y(e.target.value)})}),(0,x.jsx)(i,{error:!0,children:w}),(0,x.jsx)(`div`,{className:`row wrap`,children:(0,x.jsx)(`button`,{type:`submit`,className:`primary`,disabled:S||!Object.keys(D).length,"data-testid":`task-correction-save`,children:`保存`})})]})})}function j({members:e,config:t,userName:n,memberId:r}){return(0,x.jsx)(E,{members:e,project:t,userName:n,memberId:r})}export{j as Dashboard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{$ as e,Et as t,G as n,H as r,Tt as i,V as a,X as o,Z as s,ct as c,d as l,et as u,f as d,l as f,m as p,ot as m,p as h,q as g,u as _,x as v,z as y}from"./index-DiR0ePCJ.js";import{t as b}from"./Markdown-DorC2YjE.js";import{n as x,t as S}from"./WorkspaceTree-B4FMRlCw.js";import{t as C}from"./project-links-Dy6-B89_.js";import{t as w}from"./file-links-DnngiTbC.js";import{t as T}from"./HtmlPreview-B6aQIaMB.js";var E=i(),D=e();function O(e,t){let n=t.split(`/`).slice(0,-1);return n.map((t,r)=>x(e,n.slice(0,r+1).join(`/`))).concat(x(e,``))}function k({members:e,onRefresh:i}){let{api:a,projectId:s}=v(),[g,b]=(0,E.useState)(()=>{let t=new URLSearchParams(location.search),n=t.get(`owner`),r=c.safeParse(t.get(`path`));return n&&(d(n)||e.some(e=>e.id===n))&&r.success&&!l(r.data)?{owner:n,path:r.data}:void 0}),[T,k]=(0,E.useState)(()=>new Set(g?O(g.owner,g.path):[])),[j,M]=(0,E.useState)(()=>g?{...g,kind:`file`}:void 0),[N,P]=(0,E.useState)(0),[F,I]=(0,E.useState)(()=>{let e=new URLSearchParams(location.search);return!g&&(e.has(`owner`)||e.has(`path`))?`文件链接不完整或目标已不可用。`:``}),L=(0,E.useCallback)(async e=>{if(g)try{return{owner:g.owner,...await a.file(g.owner,g.path,void 0,e)}}catch(e){throw e instanceof u&&e.code===`FILE_NOT_FOUND`?Error(`找不到这个文件,可能已被删除或移动。`):e}},[g?.owner,g?.path,N]),R=o(L),z=R.data?.owner===g?.owner&&R.data?.file.path===g?.path?R.data:void 0;function B(e,t){let n=t.split(`/`).filter(Boolean);k(t=>{let r=new Set(t);for(let t=0;t<=n.length;t++)r.add(x(e,n.slice(0,t).join(`/`)));return r})}function V(e,n){I(``),B(e,n.split(`/`).slice(0,-1).join(`/`)),b({owner:e,path:n}),M({owner:e,path:n,kind:`file`}),history.replaceState(null,``,t(C(s,e,n)))}function H(n){if(!g)return!1;let r=w(d(g.owner)?g.path:`${g.owner}/${g.path}`,n);if(!r)return!/^[a-z][a-z0-9+.-]*:/i.test(n)&&!n.startsWith(`//`)&&(I(`该链接超出工作区,请在原仓库查看。`),!0);if(l(r.path))return I(`配置文件不在文件浏览中显示。`),!0;if(_(r.path))return location.assign(t(`/projects/${s}/memory`)),!0;let[i,...a]=r.path.split(`/`),o=e.some(e=>e.id===i),c=o?i:f,u=o?a.join(`/`):r.path;return I(``),r.directory?(B(c,u),M({owner:c,path:u,kind:`directory`})):c===g.owner&&u===g.path?r.anchor&&[...document.querySelectorAll(`.markdown h1,.markdown h2,.markdown h3,.markdown h4`)].find(e=>e.textContent?.trim().toLowerCase().replace(/\s+/g,`-`)===r.anchor.toLowerCase())?.scrollIntoView({block:`center`}):V(c,u),!0}return(0,D.jsx)(p,{"data-testid":`file-browser`,label:`文件资源管理器`,navigation:(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(h,{title:`工作区`,icon:`files`,children:(0,D.jsx)(r,{icon:`refresh`,label:`刷新文件`,"data-testid":`files-refresh`,onClick:()=>{I(``),P(e=>e+1),i()}})}),(0,D.jsx)(S,{members:e,expanded:T,selected:j,revealed:!R.loading&&!R.error&&z?{owner:z.owner,path:z.file.path,file:z.file}:void 0,onSelect:V,onToggle:(e,t)=>{M({owner:e,path:t,kind:`directory`}),k(n=>{let r=new Set(n),i=x(e,t);return r.has(i)?r.delete(i):r.add(i),r})}},N)]}),children:(0,D.jsx)(`section`,{className:`file-detail`,"data-testid":`file-preview`,"data-owner-id":g?.owner,"data-file-path":g?.path,"aria-label":m.filePreview,children:g?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(n,{error:!0,children:F||!R.loading&&R.error}),R.error&&(0,D.jsx)(`button`,{className:`file-entry-retry`,"data-testid":`files-retry`,onClick:()=>void R.reload(),children:m.retry}),R.loading?(0,D.jsx)(`p`,{className:`preview-body`,role:`status`,children:m.loading}):!R.error&&z&&(0,D.jsx)(A,{owner:z.owner,file:z.file,onLink:H},`${z.owner}:${z.file.path}:${z.file.sha256}`)]}):F?(0,D.jsx)(n,{error:!0,children:F}):(0,D.jsx)(y,{mascot:!0,title:`查看工作区文件`,description:m.pickFile})})})}function A({owner:e,file:t,onLink:i}){let{readTextBlob:c,blobUrl:l,projectId:u}=v(),[f,p]=(0,E.useState)(!1),h=t.size>524288,_=/\.(md|markdown)$/i.test(t.path),y=/\.html?$/i.test(t.path),x=(0,E.useCallback)(e=>h?Promise.resolve(void 0):c(t,e),[t.sha256,t.size,h]),S=o(x,!1,s(u,`file-body`,t.sha256));return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`header`,{className:`file-detail-header`,children:[(0,D.jsxs)(`span`,{className:`file-detail-path`,title:`${d(e)?`teamcontext`:e}/${t.path}`,children:[(0,D.jsxs)(`span`,{children:[d(e)?`teamcontext`:e,` / `]}),t.path]}),(0,D.jsxs)(g,{label:`文件操作`,children:[(_||y)&&(0,D.jsx)(r,{icon:f?`preview`:`code`,label:f?`切换为预览`:`切换为原文`,"data-testid":`file-toggle-raw`,"aria-pressed":f,onClick:()=>p(!f)}),(0,D.jsx)(`a`,{className:`icon-button`,"data-testid":`file-download`,"aria-label":m.download,title:m.download,href:l(t.sha256),download:t.path.split(`/`).at(-1),children:(0,D.jsx)(a,{name:`download`})})]})]}),h?(0,D.jsx)(`div`,{className:`empty`,children:(0,D.jsx)(`p`,{children:m.previewLarge})}):S.error?(0,D.jsxs)(`div`,{className:`preview-body`,children:[(0,D.jsx)(n,{error:!0,children:S.error}),(0,D.jsx)(`button`,{"data-testid":`file-preview-retry`,onClick:()=>void S.reload(),children:m.retry})]}):S.loading?(0,D.jsx)(`p`,{className:`preview-body`,role:`status`,children:m.loading}):(0,D.jsx)(`div`,{className:`preview-body${y&&!f?` preview-body-html`:``}`,children:y&&!f?(0,D.jsx)(T,{url:l(t.sha256),name:t.path.split(`/`).at(-1)}):_&&!f?(0,D.jsx)(`article`,{className:`markdown`,"data-testid":`file-content`,"data-format":`markdown`,children:(0,D.jsx)(b,{onLink:i,children:S.data??``})}):(0,D.jsx)(`pre`,{className:`raw`,"data-testid":`file-content`,"data-format":`text`,children:S.data})})]})}export{k as Files};
|