pi-web-ui 0.119.0 → 0.120.0
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/CHANGELOG.md +79 -0
- package/bin/hub-upgrade.mjs +33 -15
- package/bin/lib/atomic-file.mjs +90 -0
- package/dist/server/agent-service-daemon.js +44 -10
- package/dist/server/agent-service.js +803 -106
- package/dist/server/atomic-file.js +130 -5
- package/dist/server/bash-timeout.js +15 -0
- package/dist/server/bash-tool.js +68 -4
- package/dist/server/bg-servers.js +19 -13
- package/dist/server/canvas/canvas-dispatch.js +12 -1
- package/dist/server/client-state.js +56 -14
- package/dist/server/conversation-tool.js +3 -2
- package/dist/server/delegate-task.js +8 -8
- package/dist/server/device-center/group-router-runtime.js +2 -0
- package/dist/server/device-center/hub-upgrade.js +5 -10
- package/dist/server/dispatch-domain-handlers.js +96 -22
- package/dist/server/dispatch-plugin-handlers.js +10 -0
- package/dist/server/dsh/dsh-agent-service.js +9 -9
- package/dist/server/durable/durable-agent-service.js +1 -1
- package/dist/server/files-service.js +41 -19
- package/dist/server/fs-copy.js +93 -0
- package/dist/server/goal-review-gate.js +2 -2
- package/dist/server/index.js +15 -0
- package/dist/server/job-runner.js +345 -0
- package/dist/server/marker-service.js +42 -26
- package/dist/server/model-session.js +16 -0
- package/dist/server/phone-tool.js +167 -0
- package/dist/server/plan-mode.js +2 -2
- package/dist/server/plugin-api-catalog.js +1 -1
- package/dist/server/plugin-bundled.js +35 -28
- package/dist/server/plugin-installer.js +15 -0
- package/dist/server/plugin-manifest-validate.js +10 -0
- package/dist/server/plugin-materialize.js +161 -0
- package/dist/server/plugin-paths.js +60 -0
- package/dist/server/plugin-removal.js +16 -3
- package/dist/server/plugin-schedule.js +8 -7
- package/dist/server/plugin-secrets.js +7 -3
- package/dist/server/plugin-updater.js +2 -4
- package/dist/server/plugins.js +74 -38
- package/dist/server/preset-fields.js +9 -9
- package/dist/server/process-utils.js +11 -0
- package/dist/server/project-scripts.js +38 -0
- package/dist/server/prompt-composer.js +40 -21
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/quick-ask.js +3 -0
- package/dist/server/remote-ssh-service.js +39 -0
- package/dist/server/scm-commitmsg.js +2 -1
- package/dist/server/serialize.js +8 -0
- package/dist/server/session-list-index.js +246 -0
- package/dist/server/session-list-scan.js +5 -0
- package/dist/server/session-parser.js +16 -0
- package/dist/server/settings-service.js +39 -6
- package/dist/server/subagent-budget.js +68 -0
- package/dist/server/subagent-evidence.js +297 -0
- package/dist/server/subagent-helpers.js +12 -0
- package/dist/server/subagent-ledger.js +401 -0
- package/dist/server/subagent-notify.js +6 -2
- package/dist/server/subagent-security-gate.js +2 -2
- package/dist/server/subagent-settle.js +71 -0
- package/dist/server/subagents.js +497 -79
- package/dist/server/tabs.js +8 -1
- package/dist/server/terminals.js +0 -1
- package/dist/server/tool-manager.js +90 -16
- package/dist/server/tool-prompts.js +5 -1
- package/dist/server/universal/universal-service.js +1 -1
- package/dist/server/universal/universal-session.js +45 -7
- package/dist/server/vision-bridge.js +2 -0
- package/dist/server/workspace-handle.js +119 -17
- package/dist/server/workspace-queue.js +37 -0
- package/docs/README.md +25 -23
- package/docs/architecture-plugins.md +23 -3
- package/docs/device-center.md +1 -1
- package/package.json +15 -3
- package/plugins/catalog.json +13 -2
- package/themes/bases/flow-base.css +7 -16
- package/web/dist/.build-assets.json +1 -1
- package/web/dist/assets/BgTasksModal-BdOJ19Hj.js +1 -0
- package/web/dist/assets/BgTasksModal-SAH2XCkY.js +1 -0
- package/web/dist/assets/{CanvasStudio-2ydYbnpW.js → CanvasStudio-BB_Iq7pl.js} +3 -3
- package/web/dist/assets/{CanvasStudio-DizWvRjn.js → CanvasStudio-DU6O3N4u.js} +3 -3
- package/web/dist/assets/DeviceCenter-By1zVTSY.js +3 -0
- package/web/dist/assets/DeviceCenter-Cnm0Tjrx.js +3 -0
- package/web/dist/assets/{DeviceExecutionSettings-B7R9ONaq.js → DeviceExecutionSettings-qJzbI0Cf.js} +1 -1
- package/web/dist/assets/{DeviceGroups-DFU4cv5b.js → DeviceGroups-DPrQxW6B.js} +1 -1
- package/web/dist/assets/{DeviceGroups-DoaQcxKj.js → DeviceGroups-DoucyUjI.js} +1 -1
- package/web/dist/assets/{Dropdown-Btjt6Dzh.js → Dropdown-kj_NIj6e.js} +1 -1
- package/web/dist/assets/FilePreview-Bub8Y9uq.js +2 -0
- package/web/dist/assets/FilePreview-CC76Z6an.js +2 -0
- package/web/dist/assets/GlobalSearchModal-01nkgw4X.js +1 -0
- package/web/dist/assets/GlobalSearchModal-CiT6wBmR.js +1 -0
- package/web/dist/assets/{GroupConversation-DwZZrMuE.js → GroupConversation-1-lsPO1f.js} +3 -3
- package/web/dist/assets/{GroupConversation-KOi8sa5b.js → GroupConversation-HeiyW_O_.js} +3 -3
- package/web/dist/assets/{GroupWorkItems-FqAL74bC.js → GroupWorkItems-BYJv2XFj.js} +1 -1
- package/web/dist/assets/{HintTip-BOwPzBGR.js → HintTip-DFhoclDw.js} +1 -1
- package/web/dist/assets/{ModelConfigModal-DLIfWKdB.js → ModelConfigModal-D2Ro-jUZ.js} +2 -2
- package/web/dist/assets/{ModelConfigModal-B140kWrs.js → ModelConfigModal-DPc9R1pq.js} +2 -2
- package/web/dist/assets/{NativeCliPanel-BwiLazSq.js → NativeCliPanel-B108d697.js} +3 -3
- package/web/dist/assets/{NativeCliPanel-U0F_EfAU.js → NativeCliPanel-DupvGwQM.js} +3 -3
- package/web/dist/assets/{PiSetupModal-Dc7EQ4L3.js → PiSetupModal-D0HitBfd.js} +1 -1
- package/web/dist/assets/{ProviderOAuthControls-C3opmPhu.js → ProviderOAuthControls-BLKUEDde.js} +1 -1
- package/web/dist/assets/{SCMPanel-BBxQfmq9.js → SCMPanel-DDbWrUHR.js} +1 -1
- package/web/dist/assets/{SCMPanel-D2t97Vvr.js → SCMPanel-DluNcd2-.js} +1 -1
- package/web/dist/assets/SettingsModal-Cy5lRC97.css +1 -0
- package/web/dist/assets/SettingsModal-DQu18366.js +33 -0
- package/web/dist/assets/SettingsModal-Dm_haPme.js +33 -0
- package/web/dist/assets/{TermXterm-B6nCtO2b.js → TermXterm-SYc-MUk2.js} +1 -1
- package/web/dist/assets/{TerminalPanel-BWB3iSeN.js → TerminalPanel-CgA_lhVT.js} +1 -1
- package/web/dist/assets/{TerminalPanel-CAV2SosY.js → TerminalPanel-vdSIOPjD.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-B0jBPOMc.js → TuiOverlayModal-Cy1jYYIw.js} +1 -1
- package/web/dist/assets/{TuiOverlayModal-DGd6fzU6.js → TuiOverlayModal-kXY_4hV8.js} +1 -1
- package/web/dist/assets/{app-globals-CR8Ls9nE.js → app-globals-CBEscsYP.js} +9 -9
- package/web/dist/assets/{canvas-client-B0lkqTtF.js → canvas-client-Clsypfs6.js} +1 -1
- package/web/dist/assets/{desktop-BME3DkyE.js → desktop-C6D9a8HZ.js} +1 -1
- package/web/dist/assets/index-BD29OL9L.js +404 -0
- package/web/dist/assets/index-BlCxbqqr.js +404 -0
- package/web/dist/assets/index-DB55rbKC.css +1 -0
- package/web/dist/assets/{plugin-host-CVgcdBOk.js → plugin-host-VWBcq-LQ.js} +1 -1
- package/web/dist/assets/remote-ssh-client-C2eab5Kw.js +1 -0
- package/web/dist/assets/theme-CpQk_Agp.js +1 -0
- package/web/dist/index.html +10 -10
- package/web/dist/sw.js +1 -1
- package/web/dist/assets/BgTasksModal-CVHW1lRA.js +0 -1
- package/web/dist/assets/BgTasksModal-t5hxW1H6.js +0 -1
- package/web/dist/assets/DeviceCenter-CPaZNBJE.js +0 -3
- package/web/dist/assets/DeviceCenter-DsVakAYR.js +0 -3
- package/web/dist/assets/FilePreview-QGQfD2lV.js +0 -2
- package/web/dist/assets/FilePreview-qez9walH.js +0 -2
- package/web/dist/assets/GlobalSearchModal-B-cnTDJ5.js +0 -1
- package/web/dist/assets/GlobalSearchModal-BvbafjdU.js +0 -1
- package/web/dist/assets/SettingsModal-BqPQNUwF.js +0 -34
- package/web/dist/assets/SettingsModal-l7eeV-Rq.js +0 -34
- package/web/dist/assets/index-BBAQNi6v.js +0 -404
- package/web/dist/assets/index-BYW9d61A.js +0 -404
- package/web/dist/assets/index-BYWs88H2.css +0 -1
- package/web/dist/assets/remote-ssh-client-DEpvwgqG.js +0 -1
- package/web/dist/assets/theme-DVa7Z5Zu.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,B as n,Bn as r,Bt as i,Cn as a,Fn as o,H as s,Ht as c,Jt as l,K as u,Lt as d,Q as f,Qt as p,S as m,St as h,Tn as g,Ut as _,Z as v,at as y,bt as b,f as x,fn as S,gn as C,hn as w,i as T,j as E,jn as D,p as O,sn as k,tn as A,ut as j,v as M,yt as N,z as P}from"./app-globals-CR8Ls9nE.js";import{i as F,t as I}from"./react-CR5VJ85Q.js";import{t as L}from"./uuid-BzDIGCwP.js";import{Ct as R,Et as z,I as B,Rt as V,Tt as H,jt as U,lt as ee,st as te,wt as ne,x as W}from"./index-BBAQNi6v.js";import{n as G,t as K}from"./GroupWorkItems-FqAL74bC.js";import{a as re,i as q,n as ie,o as ae}from"./group-view-state-CGCzYF8k.js";import{t as oe}from"./canvas-client-B0lkqTtF.js";var J=e(F(),1);function se(e,t){return!!e&&!!t&&e.artifactTaskId===t.artifactTaskId&&e.attemptId===t.attemptId&&e.artifactId===t.artifactId&&e.artifactDigest===t.artifactDigest&&e.contractId===t.contractId&&e.contractRevision===t.contractRevision&&e.contractDigest===t.contractDigest&&e.manifestDigest===t.manifestDigest&&e.baselineCommit===t.baselineCommit&&e.repositoryId===t.repositoryId&&e.inputTree===t.inputTree&&e.outputTree===t.outputTree}function ce(e,t){return!e||!t||e.id!==t.deliveryId||e.accountId!==t.accountId||e.roomId!==t.roomId||e.conversationId!==t.conversationId?!1:e.artifactRef?t.artifactDigest===e.artifactRef.artifactDigest&&se(e.artifactRef,t.artifactRef):!t.artifactRef&&!t.artifactDigest&&!!e.commit&&e.commit===t.commit}function le(e){if(e.status===`closed`)return null;if(e.attention)return e.attention.kind;if(e.status===`queued`||e.status===`running`)return null;if(e.status===`failed`)return`failed`;if(e.status===`interrupted`)return`interrupted`;let t=e.latestDelivery??e.deliveries?.at(-1);if(!t)return null;let n=[...e.reviews??[],...e.latestReview?[e.latestReview]:[]].filter(e=>ce(t,e)).sort((e,t)=>e.createdAt-t.createdAt).at(-1);return n?n.verdict===`changes_requested`?`changes_requested`:null:`awaiting_review`}function ue(e,t){return{answer:[`等待回答`,`Waiting for an answer`],decision:[`等待决策`,`Waiting for a decision`],failed:[`执行失败,需处理`,`Execution failed — needs attention`],interrupted:[`执行中断,需处理`,`Execution interrupted — needs attention`],changes_requested:[`审查要求修改`,`Changes requested`],awaiting_review:[`已交付,待验收`,`Delivered — awaiting review`]}[e][+!t]}var de=8e4,Y=65e4,X=I();function Z(e){return!!e?.publishIntent&&(!!e.publishStop&&!e.publishStop.stopConfirmed||!e.publishReceipt&&!(e.publishStop?.closed&&e.publishStop.stopConfirmed))}async function Q(e,t,n,i=3e4){let a=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(i)]),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||String(a.status));return s}function fe({roomId:e,conversationId:t,delivery:n,review:r,onIntegrationChange:i,bots:a,disabled:o=!1,zh:s}){let[,c]=(0,J.useState)([]),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(n.botId||a[0]?.id||``),[h,g]=(0,J.useState)(n.branch||`main`),[_,v]=(0,J.useState)([]),[y,b]=(0,J.useState)(``),[x,S]=(0,J.useState)(null);(0,J.useEffect)(()=>S(null),[l?.id]);let[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(``),[D,O]=(0,J.useState)(!1),k=(0,J.useRef)(null),A=(0,J.useRef)(0),j=`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}/integrations`;(0,J.useEffect)(()=>{i?.(l)},[l,i]),(0,J.useEffect)(()=>{A.current++,k.current?.abort(),u(null),f(!1),m(n.botId||a[0]?.id||``),g(n.branch||`main`),v([]),b(``),w(!1),E(``)},[e,t,n.id,n.artifactRef?.artifactDigest,n.commit]),(0,J.useEffect)(()=>{o&&(A.current++,k.current?.abort(),w(!1))},[o]),(0,J.useEffect)(()=>{if(!D)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,E(``),f(!1);async function r(){try{let r=await Q(j,t.signal,void 0,15e3);if(t.signal.aborted||e!==A.current)return;f(r.canResumePublication===!0);let i=r.integrations||[];c(i);let a=i.filter(e=>e.deliveryId===n.id).sort((e,t)=>t.createdAt-e.createdAt)[0];u(a||null)}catch(n){!t.signal.aborted&&e===A.current&&E(n instanceof Error?n.message:String(n))}}return r(),()=>{A.current++,k.current?.abort(),w(!1)}},[D,e,t,n.id,n.commit,n.artifactRef?.artifactDigest]);let M=Z(l);(0,J.useEffect)(()=>{if(!D||o||C||!l||l.status!==`verifying`&&!M||l.deliveryId!==n.id)return;let e=l.id,t=A.current,r=new AbortController,i=5e3,a=M?de:Y,c=Date.now()+a,d=Math.ceil(a/i),p=0,m,h=()=>!r.signal.aborted&&t===A.current,g=()=>E(M?l.publishReceipt?s?`已记录发布效果,原进程停止仍未确认。请稍后回查。`:`Publication effect is recorded; original process stop remains unconfirmed. Reconcile later.`:s?`发布结果仍未知。稍后手动回查;不会自动重发写入。`:`Publication outcome remains unknown. Reconcile later; writes are never retried automatically.`:s?`验证仍在运行,稍后关闭并重新打开此面板以刷新状态。`:`Verification is still running. Close and reopen this panel later to refresh its status.`);async function _(){if(h()){if(Date.now()>=c||p>=d){g();return}p++;try{let t;if(M)t=(await Q(`${j}/${encodeURIComponent(e)}/reconcile`,r.signal,{},Math.min(de,c-Date.now()))).integration;else{let i=await Q(j,r.signal,void 0,Math.min(15e3,c-Date.now()));if(!h())return;f(i.canResumePublication===!0),t=i.integrations.find(t=>t.id===e&&t.deliveryId===n.id)}if(!h())return;if(t?.id===e&&t.deliveryId===n.id&&(u(t),t.status!==`verifying`&&!Z(t))){E(t.error??``);return}}catch(e){if(!h())return;E(e instanceof Error?e.message:String(e))}if(Date.now()>=c||p>=d){g();return}m=setTimeout(()=>void _(),Math.min(i,c-Date.now()))}}return m=setTimeout(()=>void _(),i),()=>{r.abort(),clearTimeout(m)}},[D,o,C,l?.id,l?.status,M,n.id,j,s]);async function N(){if(o||C||!p||!ee)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let r=await Q(j,t.signal,{deliveryId:n.id,targetBotId:p,targetBranch:h.trim()||`main`},de);if(t.signal.aborted||e!==A.current)return;u(r.integration),c(e=>[r.integration,...e.filter(e=>e.id!==r.integration.id)])}catch(n){!t.signal.aborted&&e===A.current&&E(n instanceof Error?n.message:String(n))}finally{e===A.current&&w(!1)}}async function P(){if(o||C||!l||!G)return;let e=[...l.verificationPlan?.commands??x??_];if(!l.verificationPlan&&!x&&y.trim()&&!e.includes(y.trim())&&e.push(y.trim()),e.length===0){E(s?`请勾选或输入至少一条验证命令`:`Select or enter at least one validation command`);return}S(e);let t=++A.current;k.current?.abort();let n=new AbortController;k.current=n,w(!0),E(``);try{let r=await Q(`${j}/${encodeURIComponent(l.id)}/verify`,n.signal,{commands:e},Y);if(n.signal.aborted||t!==A.current)return;u(r.integration),c(e=>e.map(e=>e.id===r.integration.id?r.integration:e))}catch(e){if(!n.signal.aborted&&t===A.current){E(e instanceof Error?e.message:String(e));try{let e=await Q(j,n.signal,void 0,15e3);if(!n.signal.aborted&&t===A.current){let t=e.integrations.find(e=>e.id===l.id);t&&u(t)}}catch(r){!n.signal.aborted&&t===A.current&&E(`${e instanceof Error?e.message:String(e)} · ${r instanceof Error?r.message:String(r)}`)}}}finally{t===A.current&&w(!1)}}async function F(){if(o||C||!l||!q)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let n=await Q(`${j}/${encodeURIComponent(l.id)}/apply`,t.signal,{expectedTargetSha:l.expectedTargetSha},de);if(t.signal.aborted||e!==A.current)return;u(n.integration),c(e=>e.map(e=>e.id===n.integration.id?n.integration:e))}catch(n){!t.signal.aborted&&e===A.current&&(E(n instanceof Error?n.message:String(n)),await I(l.id,t,e))}finally{e===A.current&&w(!1)}}async function I(e,t,r){try{let i=await Q(j,t.signal,void 0,15e3);if(t.signal.aborted||r!==A.current)return;f(i.canResumePublication===!0);let a=i.integrations.find(t=>t.id===e&&t.deliveryId===n.id);a&&(u(a),(a.publishReceipt||a.publishStop?.closed&&a.publishStop.stopConfirmed)&&E(a.error??``))}catch{}}async function L(e){if(o||C||!l?.publishIntent||e===`resume`&&!U)return;let t=l,n=t.publishIntent,r=++A.current;k.current?.abort();let i=new AbortController;k.current=i,w(!0),E(``);try{let a=await Q(`${j}/${encodeURIComponent(t.id)}/${e}`,i.signal,e===`resume`?{intentId:n.id,intentDigest:n.digest,candidateSha:n.candidateSha}:{},de);if(i.signal.aborted||r!==A.current)return;u(a.integration),c(e=>e.map(e=>e.id===a.integration.id?a.integration:e))}catch(e){!i.signal.aborted&&r===A.current&&(E(e instanceof Error?e.message:String(e)),await I(t.id,i,r))}finally{r===A.current&&w(!1)}}async function R(){if(o||C||!l)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let n=await Q(`${j}/${encodeURIComponent(l.id)}/cancel`,t.signal,{},de);if(t.signal.aborted||e!==A.current)return;u(n.integration),c(e=>e.map(e=>e.id===n.integration.id?n.integration:e))}catch(n){!t.signal.aborted&&e===A.current&&(E(n instanceof Error?n.message:String(n)),await I(l.id,t,e))}finally{e===A.current&&w(!1)}}let z=!!l?.publishReceipt||l?.status===`applied`,B=!!l?.publishStop?.closed&&l.publishStop.stopConfirmed,V=!!l&&!l.publishIntent&&([`applying`,`cancelling`].includes(l.status)||l.status===`failed`&&/Apply failed; check target outcome|Publication outcome unknown/.test(l.error??``)),H=!z&&(!!l?.publishIntent&&!(B&&l.publishStop?.pastEffect===`not_applied`)||V),U=d&&!!l?.publishIntent&&l.publishObservation?.intentId===l.publishIntent.id&&l.publishObservation?.intentDigest===l.publishIntent.digest&&l.publishObservation?.candidateSha===l.publishIntent.candidateSha&&l.publishObservation?.retryable===!0&&[`prepared`,`cas_rejected`].includes(l.publishObservation.phase)&&!l.publishStop?.closed&&!l.publishReceipt&&l.status!==`cancelling`,ee=(!!n.artifactRef||te())&&!M&&!V;function te(){return r?.verdict===`accepted`&&ce(n,r)}let ne=l?.status===`conflict`,W=l?.status===`cancelled`&&(!l.publishIntent||B&&l.publishStop?.pastEffect===`not_applied`),G=!l?.verification&&!l?.publishIntent&&(l?.status===`prepared`||l?.status===`failed`&&!!l.verificationPlan),K=!!l?.verificationPlan||!!x,re=r?.verdict===`accepted`&&ce(n,r),q=l?.status===`verified`&&!l.publishIntent&&!!l.verification?.digest&&re&&(n.artifactRef?se(n.artifactRef,l.artifactRef)&&r.integrationId===l.id&&r.verificationDigest===l.verification.digest&&Array.isArray(n.acceptanceCriteria)&&r.criteriaResults?.length===n.acceptanceCriteria.length&&n.acceptanceCriteria.every((e,t)=>r.criteriaResults.some(e=>e.criterionIndex===t&&e.verdict===`met`&&!!e.evidence.trim())):l.reviewId===r.id);return(0,X.jsxs)(`details`,{className:`gi-panel`,onToggle:e=>O(e.currentTarget.open),style:{marginTop:`1rem`,borderTop:`1px solid var(--border)`,paddingTop:`0.75rem`},children:[(0,X.jsxs)(`summary`,{style:{cursor:`pointer`,fontWeight:600,fontSize:`0.95rem`},children:[s?`验证与合并`:`Verify & merge`,` ·`,` `,z?s?`已合并`:`Merged`:H?s?`发布结果未知`:`Publication outcome unknown`:l?l.status:s?`待集成`:`Ready to integrate`]}),(0,X.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 0.5rem 0`,fontSize:`0.85rem`,color:`var(--text-faint)`},children:s?`先在独立工作区验证此交付${n.commit?` (${n.commit.slice(0,8)})`:``},验收通过并确认后才写入目标分支。`:`Verify this delivery${n.commit?` (${n.commit.slice(0,8)})`:``} in a separate workspace. The target branch changes only after acceptance and your confirmation.`}),T&&(0,X.jsx)(`p`,{role:`alert`,style:{color:`var(--red, #f43f5e)`,fontSize:`0.85rem`,margin:`0.25rem 0`},children:T}),l?.publishIntent&&(0,X.jsxs)(`div`,{className:`gi-publication`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`,minWidth:0},children:[(0,X.jsx)(`p`,{role:`status`,children:z?s?`已记录发布效果(证据:${l.publishReceipt?.proof??`legacy`})。`:`Publication effect recorded (proof: ${l.publishReceipt?.proof??`legacy`}).`:H?s?`发布结果未知。回查只读取证据,不会自动重新写入分支。`:`Publication outcome unknown. Reconciliation observes evidence and never retries branch writes.`:s?`已确认在发布前取消。`:`Cancellation before publication is confirmed.`}),(0,X.jsxs)(`div`,{children:[s?`发布意图:`:`Intent: `,(0,X.jsx)(`code`,{children:l.publishIntent.id})]}),(0,X.jsxs)(`div`,{children:[s?`候选提交:`:`Candidate: `,(0,X.jsx)(`code`,{children:l.publishIntent.candidateSha})]}),(0,X.jsxs)(`p`,{children:[s?`当前目标观察:`:`Current target observation: `,l.publishObservation?(0,X.jsxs)(X.Fragment,{children:[l.publishObservation.target,` · `,l.publishObservation.phase,` `,(0,X.jsx)(`code`,{children:l.publishObservation.targetSha})]}):s?`未知(尚未观察)`:`Unknown (not yet observed)`]}),l.publishStop&&(0,X.jsx)(`p`,{children:l.publishStop.stopConfirmed?l.publishStop.pastEffect===`unknown`?s?`已封闭写入并确认进程停止;历史发布结果仍未知。`:`Writes are fenced and process stop is confirmed; historical publication outcome remains unknown.`:s?`已确认封闭并停止发布操作。`:`Publication operation is fenced and confirmed stopped.`:s?`已封闭未来写入;原发布进程停止尚未确认,仍保持隔离。`:`Future writes are fenced; the original publication process has not been confirmed stopped and remains isolated.`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C,onClick:()=>void L(`reconcile`),children:s?`回查发布证据`:`Reconcile publication`}),U&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C,onClick:()=>void L(`resume`),children:s?`恢复同一发布意图`:`Resume same publication intent`})]}),z&&!l?.publishReceipt&&(0,X.jsx)(`p`,{role:`status`,children:s?`旧记录标记已应用;没有持久发布回执。`:`Legacy applied record; no durable publication receipt.`}),V&&(0,X.jsx)(`p`,{role:`status`,children:s?`旧发布记录缺少持久意图,历史结果未知。需本机核查;不会自动重试。`:`Legacy publication has no durable intent; its historical outcome is unknown. Local inspection is required; it will not retry automatically.`}),!l||W?(0,X.jsx)(`div`,{className:`gi-prepare-form`,style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,flexWrap:`wrap`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{style:{fontSize:`0.85rem`},children:[s?`目标工作区 (Bot):`:`Target Bot Workspace:`,(0,X.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),disabled:o||C,style:{marginLeft:`0.25rem`},children:a.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))})]}),(0,X.jsxs)(`label`,{style:{fontSize:`0.85rem`},children:[s?`目标分支:`:`Target Branch:`,(0,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),disabled:o||C,style:{marginLeft:`0.25rem`,width:`120px`}})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:o||C||!p||!ee,onClick:()=>void N(),children:C?s?`准备中…`:`Preparing…`:s?`准备隔离集成`:`Prepare Isolated Integration`})]})}):(0,X.jsxs)(`div`,{className:`gi-active-task`,style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`span`,{style:{fontSize:`0.85rem`,fontWeight:600},children:[s?`集成状态: `:`Status: `,(0,X.jsx)(`span`,{style:{color:z?`var(--green, #10b981)`:ne?`var(--red, #f43f5e)`:`var(--accent)`},children:H?s?`发布结果未知`:`Publication outcome unknown`:l.status})]}),(!z||M)&&!W&&!B&&(0,X.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:o||C,onClick:()=>void R(),style:{fontSize:`0.75rem`,padding:`0.2rem 0.5rem`},children:z?s?`封闭写入并确认进程停止`:`Fence writes & confirm process stop`:s?`取消集成`:`Cancel`})]}),(0,X.jsxs)(`div`,{style:{fontSize:`0.8rem`,color:`var(--text-faint)`},children:[(0,X.jsxs)(`span`,{children:[s?`目标分支: `:`Target Branch: `,(0,X.jsx)(`code`,{children:l.targetBranch})]}),l.expectedTargetSha&&(0,X.jsxs)(`span`,{style:{marginLeft:`1rem`},children:[s?`基线 SHA: `:`Target SHA: `,(0,X.jsx)(`code`,{children:l.expectedTargetSha.slice(0,8)})]}),l.newCommitSha&&(0,X.jsxs)(`span`,{style:{marginLeft:`1rem`},children:[s?`新提交 SHA: `:`New Commit SHA: `,(0,X.jsx)(`code`,{children:l.newCommitSha.slice(0,8)})]})]}),ne&&l.conflicts&&(0,X.jsxs)(`div`,{style:{background:`rgba(244, 63, 94, 0.1)`,padding:`0.5rem`,borderRadius:`4px`},children:[(0,X.jsx)(`strong`,{style:{color:`var(--red, #f43f5e)`,fontSize:`0.85rem`},children:s?`检测到合并冲突!无法自动合并:`:`Merge conflicts detected:`}),(0,X.jsx)(`ul`,{style:{margin:`0.25rem 0`,paddingLeft:`1.2rem`,fontSize:`0.8rem`},children:l.conflicts.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`code`,{children:e})},t))}),l.diff&&(0,X.jsxs)(`details`,{style:{marginTop:`0.25rem`,fontSize:`0.8rem`},children:[(0,X.jsx)(`summary`,{children:s?`查看冲突 Diff`:`View Conflict Diff`}),(0,X.jsx)(`pre`,{style:{maxHeight:`150px`,overflow:`auto`,fontSize:`0.75rem`},children:l.diff})]})]}),l.diff&&!ne&&(0,X.jsxs)(`details`,{style:{fontSize:`0.85rem`,margin:`0.25rem 0`},children:[(0,X.jsx)(`summary`,{children:s?`集成 Diff 预览`:`Integration Diff Preview`}),(0,X.jsx)(`pre`,{style:{maxHeight:`200px`,overflow:`auto`,fontSize:`0.75rem`,background:`var(--code-bg, rgba(0,0,0,0.2))`,padding:`0.5rem`,borderRadius:`4px`},children:l.diff})]}),G&&(0,X.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`4px`,padding:`0.5rem`,background:`var(--bg-elev2)`},children:[(0,X.jsx)(`div`,{style:{fontSize:`0.85rem`,fontWeight:600,marginBottom:`0.25rem`},children:s?`验证命令`:`Verification commands`}),(0,X.jsx)(`p`,{style:{fontSize:`0.75rem`,color:`var(--text-faint)`,margin:`0 0 0.25rem 0`},children:s?K?`命令已锁定。重试会运行相同命令;更换命令需要新建验证。`:`请由账户所有者选择或填写命令。点击验证即授权执行并锁定这些命令。`:K?`Commands are locked. A retry runs the same commands; start a new verification to change them.`:`As the account owner, select or enter commands. Clicking Verify authorizes execution and locks these commands.`}),K&&(0,X.jsx)(`pre`,{children:(l.verificationPlan?.commands??x??[]).join(`
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{A as t,B as n,Bn as r,Bt as i,Cn as a,Fn as o,H as s,Ht as c,Jt as l,K as u,Lt as d,Q as f,Qt as p,S as m,St as h,Tn as g,Ut as _,Z as v,at as y,bt as b,f as x,fn as S,gn as C,hn as w,i as T,j as E,jn as D,p as O,sn as k,tn as A,ut as j,v as M,yt as N,z as P}from"./app-globals-CBEscsYP.js";import{i as F,t as I}from"./react-CR5VJ85Q.js";import{t as L}from"./uuid-BzDIGCwP.js";import{Ct as R,Et as z,Ft as B,Ht as V,I as H,Tt as U,lt as ee,st as te,wt as ne,y as W}from"./index-BlCxbqqr.js";import{n as G,t as K}from"./GroupWorkItems-BYJv2XFj.js";import{a as re,i as q,n as ie,o as ae}from"./group-view-state-CGCzYF8k.js";import{t as oe}from"./canvas-client-Clsypfs6.js";var J=e(F(),1);function se(e,t){return!!e&&!!t&&e.artifactTaskId===t.artifactTaskId&&e.attemptId===t.attemptId&&e.artifactId===t.artifactId&&e.artifactDigest===t.artifactDigest&&e.contractId===t.contractId&&e.contractRevision===t.contractRevision&&e.contractDigest===t.contractDigest&&e.manifestDigest===t.manifestDigest&&e.baselineCommit===t.baselineCommit&&e.repositoryId===t.repositoryId&&e.inputTree===t.inputTree&&e.outputTree===t.outputTree}function ce(e,t){return!e||!t||e.id!==t.deliveryId||e.accountId!==t.accountId||e.roomId!==t.roomId||e.conversationId!==t.conversationId?!1:e.artifactRef?t.artifactDigest===e.artifactRef.artifactDigest&&se(e.artifactRef,t.artifactRef):!t.artifactRef&&!t.artifactDigest&&!!e.commit&&e.commit===t.commit}function le(e){if(e.status===`closed`)return null;if(e.attention)return e.attention.kind;if(e.status===`queued`||e.status===`running`)return null;if(e.status===`failed`)return`failed`;if(e.status===`interrupted`)return`interrupted`;let t=e.latestDelivery??e.deliveries?.at(-1);if(!t)return null;let n=[...e.reviews??[],...e.latestReview?[e.latestReview]:[]].filter(e=>ce(t,e)).sort((e,t)=>e.createdAt-t.createdAt).at(-1);return n?n.verdict===`changes_requested`?`changes_requested`:null:`awaiting_review`}function ue(e,t){return{answer:[`等待回答`,`Waiting for an answer`],decision:[`等待决策`,`Waiting for a decision`],failed:[`执行失败,需处理`,`Execution failed — needs attention`],interrupted:[`执行中断,需处理`,`Execution interrupted — needs attention`],changes_requested:[`审查要求修改`,`Changes requested`],awaiting_review:[`已交付,待验收`,`Delivered — awaiting review`]}[e][+!t]}var de=8e4,Y=65e4,X=I();function Z(e){return!!e?.publishIntent&&(!!e.publishStop&&!e.publishStop.stopConfirmed||!e.publishReceipt&&!(e.publishStop?.closed&&e.publishStop.stopConfirmed))}async function Q(e,t,n,i=3e4){let a=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(i)]),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),s=await a.json().catch(()=>({}));if(!a.ok)throw Error(s.error||String(a.status));return s}function fe({roomId:e,conversationId:t,delivery:n,review:r,onIntegrationChange:i,bots:a,disabled:o=!1,zh:s}){let[,c]=(0,J.useState)([]),[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(!1),[p,m]=(0,J.useState)(n.botId||a[0]?.id||``),[h,g]=(0,J.useState)(n.branch||`main`),[_,v]=(0,J.useState)([]),[y,b]=(0,J.useState)(``),[x,S]=(0,J.useState)(null);(0,J.useEffect)(()=>S(null),[l?.id]);let[C,w]=(0,J.useState)(!1),[T,E]=(0,J.useState)(``),[D,O]=(0,J.useState)(!1),k=(0,J.useRef)(null),A=(0,J.useRef)(0),j=`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t)}/integrations`;(0,J.useEffect)(()=>{i?.(l)},[l,i]),(0,J.useEffect)(()=>{A.current++,k.current?.abort(),u(null),f(!1),m(n.botId||a[0]?.id||``),g(n.branch||`main`),v([]),b(``),w(!1),E(``)},[e,t,n.id,n.artifactRef?.artifactDigest,n.commit]),(0,J.useEffect)(()=>{o&&(A.current++,k.current?.abort(),w(!1))},[o]),(0,J.useEffect)(()=>{if(!D)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,E(``),f(!1);async function r(){try{let r=await Q(j,t.signal,void 0,15e3);if(t.signal.aborted||e!==A.current)return;f(r.canResumePublication===!0);let i=r.integrations||[];c(i);let a=i.filter(e=>e.deliveryId===n.id).sort((e,t)=>t.createdAt-e.createdAt)[0];u(a||null)}catch(n){!t.signal.aborted&&e===A.current&&E(n instanceof Error?n.message:String(n))}}return r(),()=>{A.current++,k.current?.abort(),w(!1)}},[D,e,t,n.id,n.commit,n.artifactRef?.artifactDigest]);let M=Z(l);(0,J.useEffect)(()=>{if(!D||o||C||!l||l.status!==`verifying`&&!M||l.deliveryId!==n.id)return;let e=l.id,t=A.current,r=new AbortController,i=5e3,a=M?de:Y,c=Date.now()+a,d=Math.ceil(a/i),p=0,m,h=()=>!r.signal.aborted&&t===A.current,g=()=>E(M?l.publishReceipt?s?`已记录发布效果,原进程停止仍未确认。请稍后回查。`:`Publication effect is recorded; original process stop remains unconfirmed. Reconcile later.`:s?`发布结果仍未知。稍后手动回查;不会自动重发写入。`:`Publication outcome remains unknown. Reconcile later; writes are never retried automatically.`:s?`验证仍在运行,稍后关闭并重新打开此面板以刷新状态。`:`Verification is still running. Close and reopen this panel later to refresh its status.`);async function _(){if(h()){if(Date.now()>=c||p>=d){g();return}p++;try{let t;if(M)t=(await Q(`${j}/${encodeURIComponent(e)}/reconcile`,r.signal,{},Math.min(de,c-Date.now()))).integration;else{let i=await Q(j,r.signal,void 0,Math.min(15e3,c-Date.now()));if(!h())return;f(i.canResumePublication===!0),t=i.integrations.find(t=>t.id===e&&t.deliveryId===n.id)}if(!h())return;if(t?.id===e&&t.deliveryId===n.id&&(u(t),t.status!==`verifying`&&!Z(t))){E(t.error??``);return}}catch(e){if(!h())return;E(e instanceof Error?e.message:String(e))}if(Date.now()>=c||p>=d){g();return}m=setTimeout(()=>void _(),Math.min(i,c-Date.now()))}}return m=setTimeout(()=>void _(),i),()=>{r.abort(),clearTimeout(m)}},[D,o,C,l?.id,l?.status,M,n.id,j,s]);async function N(){if(o||C||!p||!ee)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let r=await Q(j,t.signal,{deliveryId:n.id,targetBotId:p,targetBranch:h.trim()||`main`},de);if(t.signal.aborted||e!==A.current)return;u(r.integration),c(e=>[r.integration,...e.filter(e=>e.id!==r.integration.id)])}catch(n){!t.signal.aborted&&e===A.current&&E(n instanceof Error?n.message:String(n))}finally{e===A.current&&w(!1)}}async function P(){if(o||C||!l||!G)return;let e=[...l.verificationPlan?.commands??x??_];if(!l.verificationPlan&&!x&&y.trim()&&!e.includes(y.trim())&&e.push(y.trim()),e.length===0){E(s?`请勾选或输入至少一条验证命令`:`Select or enter at least one validation command`);return}S(e);let t=++A.current;k.current?.abort();let n=new AbortController;k.current=n,w(!0),E(``);try{let r=await Q(`${j}/${encodeURIComponent(l.id)}/verify`,n.signal,{commands:e},Y);if(n.signal.aborted||t!==A.current)return;u(r.integration),c(e=>e.map(e=>e.id===r.integration.id?r.integration:e))}catch(e){if(!n.signal.aborted&&t===A.current){E(e instanceof Error?e.message:String(e));try{let e=await Q(j,n.signal,void 0,15e3);if(!n.signal.aborted&&t===A.current){let t=e.integrations.find(e=>e.id===l.id);t&&u(t)}}catch(r){!n.signal.aborted&&t===A.current&&E(`${e instanceof Error?e.message:String(e)} · ${r instanceof Error?r.message:String(r)}`)}}}finally{t===A.current&&w(!1)}}async function F(){if(o||C||!l||!q)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let n=await Q(`${j}/${encodeURIComponent(l.id)}/apply`,t.signal,{expectedTargetSha:l.expectedTargetSha},de);if(t.signal.aborted||e!==A.current)return;u(n.integration),c(e=>e.map(e=>e.id===n.integration.id?n.integration:e))}catch(n){!t.signal.aborted&&e===A.current&&(E(n instanceof Error?n.message:String(n)),await I(l.id,t,e))}finally{e===A.current&&w(!1)}}async function I(e,t,r){try{let i=await Q(j,t.signal,void 0,15e3);if(t.signal.aborted||r!==A.current)return;f(i.canResumePublication===!0);let a=i.integrations.find(t=>t.id===e&&t.deliveryId===n.id);a&&(u(a),(a.publishReceipt||a.publishStop?.closed&&a.publishStop.stopConfirmed)&&E(a.error??``))}catch{}}async function L(e){if(o||C||!l?.publishIntent||e===`resume`&&!U)return;let t=l,n=t.publishIntent,r=++A.current;k.current?.abort();let i=new AbortController;k.current=i,w(!0),E(``);try{let a=await Q(`${j}/${encodeURIComponent(t.id)}/${e}`,i.signal,e===`resume`?{intentId:n.id,intentDigest:n.digest,candidateSha:n.candidateSha}:{},de);if(i.signal.aborted||r!==A.current)return;u(a.integration),c(e=>e.map(e=>e.id===a.integration.id?a.integration:e))}catch(e){!i.signal.aborted&&r===A.current&&(E(e instanceof Error?e.message:String(e)),await I(t.id,i,r))}finally{r===A.current&&w(!1)}}async function R(){if(o||C||!l)return;let e=++A.current;k.current?.abort();let t=new AbortController;k.current=t,w(!0),E(``);try{let n=await Q(`${j}/${encodeURIComponent(l.id)}/cancel`,t.signal,{},de);if(t.signal.aborted||e!==A.current)return;u(n.integration),c(e=>e.map(e=>e.id===n.integration.id?n.integration:e))}catch(n){!t.signal.aborted&&e===A.current&&(E(n instanceof Error?n.message:String(n)),await I(l.id,t,e))}finally{e===A.current&&w(!1)}}let z=!!l?.publishReceipt||l?.status===`applied`,B=!!l?.publishStop?.closed&&l.publishStop.stopConfirmed,V=!!l&&!l.publishIntent&&([`applying`,`cancelling`].includes(l.status)||l.status===`failed`&&/Apply failed; check target outcome|Publication outcome unknown/.test(l.error??``)),H=!z&&(!!l?.publishIntent&&!(B&&l.publishStop?.pastEffect===`not_applied`)||V),U=d&&!!l?.publishIntent&&l.publishObservation?.intentId===l.publishIntent.id&&l.publishObservation?.intentDigest===l.publishIntent.digest&&l.publishObservation?.candidateSha===l.publishIntent.candidateSha&&l.publishObservation?.retryable===!0&&[`prepared`,`cas_rejected`].includes(l.publishObservation.phase)&&!l.publishStop?.closed&&!l.publishReceipt&&l.status!==`cancelling`,ee=(!!n.artifactRef||te())&&!M&&!V;function te(){return r?.verdict===`accepted`&&ce(n,r)}let ne=l?.status===`conflict`,W=l?.status===`cancelled`&&(!l.publishIntent||B&&l.publishStop?.pastEffect===`not_applied`),G=!l?.verification&&!l?.publishIntent&&(l?.status===`prepared`||l?.status===`failed`&&!!l.verificationPlan),K=!!l?.verificationPlan||!!x,re=r?.verdict===`accepted`&&ce(n,r),q=l?.status===`verified`&&!l.publishIntent&&!!l.verification?.digest&&re&&(n.artifactRef?se(n.artifactRef,l.artifactRef)&&r.integrationId===l.id&&r.verificationDigest===l.verification.digest&&Array.isArray(n.acceptanceCriteria)&&r.criteriaResults?.length===n.acceptanceCriteria.length&&n.acceptanceCriteria.every((e,t)=>r.criteriaResults.some(e=>e.criterionIndex===t&&e.verdict===`met`&&!!e.evidence.trim())):l.reviewId===r.id);return(0,X.jsxs)(`details`,{className:`gi-panel`,onToggle:e=>O(e.currentTarget.open),style:{marginTop:`1rem`,borderTop:`1px solid var(--border)`,paddingTop:`0.75rem`},children:[(0,X.jsxs)(`summary`,{style:{cursor:`pointer`,fontWeight:600,fontSize:`0.95rem`},children:[s?`验证与合并`:`Verify & merge`,` ·`,` `,z?s?`已合并`:`Merged`:H?s?`发布结果未知`:`Publication outcome unknown`:l?l.status:s?`待集成`:`Ready to integrate`]}),(0,X.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,X.jsx)(`p`,{style:{margin:`0 0 0.5rem 0`,fontSize:`0.85rem`,color:`var(--text-faint)`},children:s?`先在独立工作区验证此交付${n.commit?` (${n.commit.slice(0,8)})`:``},验收通过并确认后才写入目标分支。`:`Verify this delivery${n.commit?` (${n.commit.slice(0,8)})`:``} in a separate workspace. The target branch changes only after acceptance and your confirmation.`}),T&&(0,X.jsx)(`p`,{role:`alert`,style:{color:`var(--red, #f43f5e)`,fontSize:`0.85rem`,margin:`0.25rem 0`},children:T}),l?.publishIntent&&(0,X.jsxs)(`div`,{className:`gi-publication`,style:{overflowWrap:`anywhere`,wordBreak:`break-word`,minWidth:0},children:[(0,X.jsx)(`p`,{role:`status`,children:z?s?`已记录发布效果(证据:${l.publishReceipt?.proof??`legacy`})。`:`Publication effect recorded (proof: ${l.publishReceipt?.proof??`legacy`}).`:H?s?`发布结果未知。回查只读取证据,不会自动重新写入分支。`:`Publication outcome unknown. Reconciliation observes evidence and never retries branch writes.`:s?`已确认在发布前取消。`:`Cancellation before publication is confirmed.`}),(0,X.jsxs)(`div`,{children:[s?`发布意图:`:`Intent: `,(0,X.jsx)(`code`,{children:l.publishIntent.id})]}),(0,X.jsxs)(`div`,{children:[s?`候选提交:`:`Candidate: `,(0,X.jsx)(`code`,{children:l.publishIntent.candidateSha})]}),(0,X.jsxs)(`p`,{children:[s?`当前目标观察:`:`Current target observation: `,l.publishObservation?(0,X.jsxs)(X.Fragment,{children:[l.publishObservation.target,` · `,l.publishObservation.phase,` `,(0,X.jsx)(`code`,{children:l.publishObservation.targetSha})]}):s?`未知(尚未观察)`:`Unknown (not yet observed)`]}),l.publishStop&&(0,X.jsx)(`p`,{children:l.publishStop.stopConfirmed?l.publishStop.pastEffect===`unknown`?s?`已封闭写入并确认进程停止;历史发布结果仍未知。`:`Writes are fenced and process stop is confirmed; historical publication outcome remains unknown.`:s?`已确认封闭并停止发布操作。`:`Publication operation is fenced and confirmed stopped.`:s?`已封闭未来写入;原发布进程停止尚未确认,仍保持隔离。`:`Future writes are fenced; the original publication process has not been confirmed stopped and remains isolated.`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C,onClick:()=>void L(`reconcile`),children:s?`回查发布证据`:`Reconcile publication`}),U&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C,onClick:()=>void L(`resume`),children:s?`恢复同一发布意图`:`Resume same publication intent`})]}),z&&!l?.publishReceipt&&(0,X.jsx)(`p`,{role:`status`,children:s?`旧记录标记已应用;没有持久发布回执。`:`Legacy applied record; no durable publication receipt.`}),V&&(0,X.jsx)(`p`,{role:`status`,children:s?`旧发布记录缺少持久意图,历史结果未知。需本机核查;不会自动重试。`:`Legacy publication has no durable intent; its historical outcome is unknown. Local inspection is required; it will not retry automatically.`}),!l||W?(0,X.jsx)(`div`,{className:`gi-prepare-form`,style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,flexWrap:`wrap`,alignItems:`center`},children:[(0,X.jsxs)(`label`,{style:{fontSize:`0.85rem`},children:[s?`目标工作区 (Bot):`:`Target Bot Workspace:`,(0,X.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),disabled:o||C,style:{marginLeft:`0.25rem`},children:a.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name||e.id},e.id))})]}),(0,X.jsxs)(`label`,{style:{fontSize:`0.85rem`},children:[s?`目标分支:`:`Target Branch:`,(0,X.jsx)(`input`,{type:`text`,value:h,onChange:e=>g(e.target.value),disabled:o||C,style:{marginLeft:`0.25rem`,width:`120px`}})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:o||C||!p||!ee,onClick:()=>void N(),children:C?s?`准备中…`:`Preparing…`:s?`准备隔离集成`:`Prepare Isolated Integration`})]})}):(0,X.jsxs)(`div`,{className:`gi-active-task`,style:{display:`flex`,flexDirection:`column`,gap:`0.5rem`},children:[(0,X.jsxs)(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`},children:[(0,X.jsxs)(`span`,{style:{fontSize:`0.85rem`,fontWeight:600},children:[s?`集成状态: `:`Status: `,(0,X.jsx)(`span`,{style:{color:z?`var(--green, #10b981)`:ne?`var(--red, #f43f5e)`:`var(--accent)`},children:H?s?`发布结果未知`:`Publication outcome unknown`:l.status})]}),(!z||M)&&!W&&!B&&(0,X.jsx)(`button`,{type:`button`,className:`btn danger`,disabled:o||C,onClick:()=>void R(),style:{fontSize:`0.75rem`,padding:`0.2rem 0.5rem`},children:z?s?`封闭写入并确认进程停止`:`Fence writes & confirm process stop`:s?`取消集成`:`Cancel`})]}),(0,X.jsxs)(`div`,{style:{fontSize:`0.8rem`,color:`var(--text-faint)`},children:[(0,X.jsxs)(`span`,{children:[s?`目标分支: `:`Target Branch: `,(0,X.jsx)(`code`,{children:l.targetBranch})]}),l.expectedTargetSha&&(0,X.jsxs)(`span`,{style:{marginLeft:`1rem`},children:[s?`基线 SHA: `:`Target SHA: `,(0,X.jsx)(`code`,{children:l.expectedTargetSha.slice(0,8)})]}),l.newCommitSha&&(0,X.jsxs)(`span`,{style:{marginLeft:`1rem`},children:[s?`新提交 SHA: `:`New Commit SHA: `,(0,X.jsx)(`code`,{children:l.newCommitSha.slice(0,8)})]})]}),ne&&l.conflicts&&(0,X.jsxs)(`div`,{style:{background:`rgba(244, 63, 94, 0.1)`,padding:`0.5rem`,borderRadius:`4px`},children:[(0,X.jsx)(`strong`,{style:{color:`var(--red, #f43f5e)`,fontSize:`0.85rem`},children:s?`检测到合并冲突!无法自动合并:`:`Merge conflicts detected:`}),(0,X.jsx)(`ul`,{style:{margin:`0.25rem 0`,paddingLeft:`1.2rem`,fontSize:`0.8rem`},children:l.conflicts.map((e,t)=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`code`,{children:e})},t))}),l.diff&&(0,X.jsxs)(`details`,{style:{marginTop:`0.25rem`,fontSize:`0.8rem`},children:[(0,X.jsx)(`summary`,{children:s?`查看冲突 Diff`:`View Conflict Diff`}),(0,X.jsx)(`pre`,{style:{maxHeight:`150px`,overflow:`auto`,fontSize:`0.75rem`},children:l.diff})]})]}),l.diff&&!ne&&(0,X.jsxs)(`details`,{style:{fontSize:`0.85rem`,margin:`0.25rem 0`},children:[(0,X.jsx)(`summary`,{children:s?`集成 Diff 预览`:`Integration Diff Preview`}),(0,X.jsx)(`pre`,{style:{maxHeight:`200px`,overflow:`auto`,fontSize:`0.75rem`,background:`var(--code-bg, rgba(0,0,0,0.2))`,padding:`0.5rem`,borderRadius:`4px`},children:l.diff})]}),G&&(0,X.jsxs)(`div`,{style:{border:`1px solid var(--border)`,borderRadius:`4px`,padding:`0.5rem`,background:`var(--bg-elev2)`},children:[(0,X.jsx)(`div`,{style:{fontSize:`0.85rem`,fontWeight:600,marginBottom:`0.25rem`},children:s?`验证命令`:`Verification commands`}),(0,X.jsx)(`p`,{style:{fontSize:`0.75rem`,color:`var(--text-faint)`,margin:`0 0 0.25rem 0`},children:s?K?`命令已锁定。重试会运行相同命令;更换命令需要新建验证。`:`请由账户所有者选择或填写命令。点击验证即授权执行并锁定这些命令。`:K?`Commands are locked. A retry runs the same commands; start a new verification to change them.`:`As the account owner, select or enter commands. Clicking Verify authorizes execution and locks these commands.`}),K&&(0,X.jsx)(`pre`,{children:(l.verificationPlan?.commands??x??[]).join(`
|
|
2
2
|
`)}),!K&&n.checks.length>0&&(0,X.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`,gap:`0.25rem`,margin:`0.25rem 0`},children:n.checks.map((e,t)=>(0,X.jsxs)(`label`,{style:{fontSize:`0.8rem`,display:`flex`,alignItems:`center`,gap:`0.25rem`},children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:_.includes(e.command),disabled:o||C||K,onChange:t=>{t.target.checked?v(t=>[...t,e.command]):v(t=>t.filter(t=>t!==e.command))}}),(0,X.jsx)(`code`,{children:e.command}),(0,X.jsxs)(`span`,{style:{color:`var(--text-faint)`,fontSize:`0.75rem`},children:[`(`,s?`Bot 自述结果:`:`Bot claimed:`,` `,e.status,`)`]})]},t))}),(0,X.jsxs)(`div`,{style:{display:`flex`,gap:`0.5rem`,marginTop:`0.25rem`},children:[(0,X.jsx)(`input`,{type:`text`,placeholder:s?`自定义验证命令,如 npm test`:`Custom command, e.g. npm test`,value:y,onChange:e=>b(e.target.value),disabled:o||C||K,style:{flex:1,fontSize:`0.8rem`}}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C||!K&&_.length===0&&!y.trim(),onClick:()=>void P(),style:{fontSize:`0.8rem`},children:C&&l.status===`verifying`?s?`验证中…`:`Verifying…`:s?`验证`:`Verify`})]}),l.validationCommands.length>0&&(0,X.jsxs)(`div`,{style:{marginTop:`0.5rem`},children:[(0,X.jsx)(`div`,{style:{fontSize:`0.8rem`,fontWeight:600},children:s?`验证结果:`:`Validation Results:`}),l.validationCommands.map((e,t)=>(0,X.jsxs)(`div`,{style:{fontSize:`0.75rem`,margin:`0.25rem 0`},children:[(0,X.jsx)(`code`,{children:e.command}),`:`,` `,(0,X.jsx)(`span`,{style:{color:e.status===`passed`?`var(--green, #10b981)`:`var(--red, #f43f5e)`,fontWeight:600},children:e.status}),e.exitCode!==void 0&&` (exit ${e.exitCode})`,e.output&&(0,X.jsx)(`pre`,{style:{maxHeight:`100px`,overflow:`auto`,margin:`0.1rem 0`,padding:`0.25rem`,background:`rgba(0,0,0,0.15)`},children:e.output})]},t))]})]}),l.verification&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{role:`status`,children:s?`验证已成功并锁定。重新验证请新建整合。`:`Verification succeeded and is locked. Start a new integration to verify again.`}),(0,X.jsxs)(`details`,{children:[(0,X.jsx)(`summary`,{children:s?`验证结果`:`Verification results`}),l.verification.results.map((e,t)=>(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`code`,{children:e.command}),` · `,e.status,` (exit `,e.exitCode,`)`,(0,X.jsx)(`pre`,{style:{maxHeight:`150px`,overflow:`auto`},children:e.outputPreview})]},t))]})]}),l.verification&&!q&&!z&&!l.publishIntent&&(0,X.jsx)(`p`,{children:s?`请完成与本次验证对应的独立验收,再确认合并。`:`Complete an independent review for this verification before confirming the merge.`}),!z&&ee&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||C,onClick:()=>void N(),children:s?`新建整合与验证`:`Start a new integration & verification`}),q&&(0,X.jsxs)(`div`,{style:{marginTop:`0.5rem`,display:`flex`,alignItems:`center`,gap:`0.5rem`},children:[(0,X.jsx)(`button`,{type:`button`,className:`btn primary`,disabled:o||C,onClick:()=>void F(),style:{fontSize:`0.85rem`},children:C&&l.status===`applying`?s?`正在写入目标分支…`:`Writing to target branch…`:s?`确认合并写入 ${l.targetBranch}`:`Confirm & Merge into ${l.targetBranch}`}),(0,X.jsx)(`span`,{style:{fontSize:`0.75rem`,color:`var(--text-faint)`},children:s?`(点击即确认合并,绝不强制覆盖或自动推送)`:`(Explicit confirmation; never forces or pushes)`})]}),z&&(0,X.jsxs)(`div`,{style:{color:`var(--green, #10b981)`,fontSize:`0.85rem`,fontWeight:600,marginTop:`0.25rem`},children:[`✓`,` `,s?`已记录分支 ${l.targetBranch} 的历史发布结果;当前分支状态以上方观察为准。`:`Historical publication recorded for branch ${l.targetBranch}; see the current target observation above.`]})]})]})]})}async function pe(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(15e3)]),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||String(i.status));return a}function me({roomId:e,conversations:t,bots:n,disabled:r,error:i,onRefresh:o}){let{locale:s}=a(),c=D(s),[l,u]=(0,J.useState)(!0),d=t.filter(e=>le(e)).length,f=l?t.filter(e=>le(e)):t;return(0,X.jsxs)(`details`,{className:`gd-panel`,children:[(0,X.jsxs)(`summary`,{children:[c?`需要我处理`:`Needs attention`,` · `,d,` · `,c?`全部对话`:`All conversations`,` `,t.length]}),(0,X.jsxs)(`div`,{className:`gd-content`,children:[i&&(0,X.jsx)(`p`,{role:`alert`,children:i}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:l,onChange:e=>u(e.target.checked)}),c?`仅显示需要处理的事项`:`Show only items needing attention`]}),!f.length&&(0,X.jsx)(`p`,{children:l?c?`当前没有需要处理的事项。`:`Nothing needs attention right now.`:c?`暂无 Bot 对话。`:`No Bot conversations yet.`}),f.map(t=>(0,X.jsx)(he,{roomId:e,conversation:t,bot:n.find(e=>e.id===t.botId)?.name??t.botId,bots:n,disabled:r||!!i,onRefresh:o,zh:c},`${e}:${t.id}`))]})]})}function he({roomId:e,conversation:t,bot:n,bots:r=[],disabled:i,onRefresh:a,zh:o}){let s=le(t),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(``),[f,p]=(0,J.useState)(!1),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(null),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),w=(0,J.useRef)(!1);(0,J.useEffect)(()=>{T.current?.abort(),T.current=null,w.current=!1,_(null),C(!1)},[t.latestDelivery?.id,t.reviewCount]);let T=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>T.current?.abort(),[]),(0,J.useEffect)(()=>{i&&T.current?.abort()},[i]);let E=t.deliveries??(t.latestDelivery?[t.latestDelivery]:[]),D=t.reviews??(t.latestReview?[t.latestReview]:[]),O=E[E.length-1],k=`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t.id)}`;async function A(){if(w.current||i||T.current&&!T.current.signal.aborted)return;let e=new AbortController;T.current=e,C(!0);try{let t=await pe(k,e.signal);if(e.signal.aborted)return;w.current=!0,_(t),y(``)}catch(t){e.signal.aborted||y(t instanceof Error?t.message:String(t))}finally{e.signal.aborted||C(!1),T.current===e&&(T.current=null)}}return(0,J.useEffect)(()=>{b&&A()},[b,t.latestDelivery?.id,t.reviewCount,i]),(0,X.jsxs)(`section`,{className:`gd-conversation`,"aria-label":`${n} · ${t.name}`,children:[(0,X.jsxs)(`strong`,{children:[n,` · `,t.name||(o?`未命名对话`:`Untitled conversation`)]}),(0,X.jsxs)(`p`,{children:[o?`执行状态`:`Execution status`,`: `,t.status]}),t.closedReason&&(0,X.jsx)(`p`,{role:`status`,children:t.closedReason===`device_revoked`?o?`承载 Bot 的设备已解绑,此会话已停止。`:`The device hosting this Bot was revoked, so the conversation stopped.`:o?`此会话已停止。`:`This conversation was stopped.`}),t.stale&&(0,X.jsx)(`p`,{role:`status`,children:o?`Bot 配置已变更(revision/设备/成员),此会话无法继续;请新建对话。`:`This Bot's configuration changed (revision, device or membership); start a new conversation.`}),t.status!==`closed`&&!t.stale&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:i||f,onClick:async()=>{if(!(i||f)){p(!0),h(``);try{await pe(`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t.id)}/stop`,AbortSignal.timeout(15e3),{}),a?.()}catch(e){h(e instanceof Error?e.message:String(e))}finally{p(!1)}}},children:o?`关闭会话`:`Close conversation`}),m&&(0,X.jsx)(`p`,{role:`alert`,children:m})]}),(t.status===`closed`||t.stale)&&!t.deliveryCount&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:i||c,onClick:async()=>{if(!(i||c)){l(!0),d(``);try{await pe(`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t.id)}/delete`,AbortSignal.timeout(15e3),{}),a?.()}catch(e){d(e instanceof Error?e.message:String(e))}finally{l(!1)}}},children:o?`删除会话(释放容量)`:`Delete conversation (free capacity)`}),u&&(0,X.jsx)(`p`,{role:`alert`,children:u})]}),s&&(0,X.jsx)(`p`,{role:`status`,children:ue(s,o)}),t.attention&&(0,X.jsx)(ge,{roomId:e,conversation:t,disabled:i,zh:o},t.attention.id),(s===`failed`||s===`interrupted`||s===`changes_requested`)&&(0,X.jsx)(`p`,{children:o?`在输入框输入 @,选择此 Bot 的原对话补充要求或继续处理。`:`Type @ in the composer and select this Bot's existing conversation to continue.`}),t.deliverySummaryTruncated&&!g&&(0,X.jsx)(`p`,{children:o?`当前为摘要,请展开完整交付后验收。`:`Summary only. Load the full delivery before reviewing.`}),O?(0,X.jsx)(_e,{roomId:e,conversationId:t.id,bots:r,delivery:g?.deliveries.find(e=>e.id===O.id)??O,reviews:[...g?.reviews??[],...D],base:k,disabled:i||!!t.deliverySummaryTruncated&&!g,zh:o},O.id):(0,X.jsx)(`p`,{children:o?`未交付(执行结束不代表已交付)`:`Not delivered (execution ending does not imply delivery)`}),O&&(0,X.jsxs)(`details`,{className:`gd-history`,onToggle:e=>{x(e.currentTarget.open)},children:[(0,X.jsxs)(`summary`,{children:[o?`完整交付与历史`:`Full delivery & history`,` · `,t.deliveryCount??E.length]}),S&&(0,X.jsx)(`p`,{role:`status`,children:o?`加载中…`:`Loading…`}),v&&(0,X.jsxs)(`p`,{role:`alert`,children:[v,` `,(0,X.jsx)(`button`,{type:`button`,className:`btn`,onClick:()=>void A(),children:o?`重试`:`Retry`})]}),(t.deliveries??g?.deliveries??[]).filter(e=>e.id!==O?.id).map(e=>(0,X.jsx)(_e,{delivery:e,reviews:t.reviews??g?.reviews??[],base:k,disabled:i,readOnly:!0,zh:o},e.id))]})]})}function ge({roomId:e,conversation:t,disabled:n,zh:r}){let[i,a]=(0,J.useState)(``),[o,s]=(0,J.useState)(``),[c,l]=(0,J.useState)(!1),[u,d]=(0,J.useState)(!1),f=(0,J.useRef)(null),p=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>f.current?.abort(),[]),(0,J.useEffect)(()=>{n&&f.current?.abort()},[n]);async function m(){if(n||c||u||!i.trim()||!t.attention)return;let r=new AbortController;f.current=r,p.current?.text!==i.trim()&&(p.current={text:i.trim(),key:L()}),l(!0);try{await pe(`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(t.id)}/messages`,r.signal,{text:p.current.text,attentionId:t.attention.id,idempotencyKey:p.current.key}),r.signal.aborted||(d(!0),s(``))}catch(e){r.signal.aborted||s(e instanceof Error?e.message:String(e))}finally{f.current===r&&(f.current=null,l(!1))}}return(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{children:t.attention?.question}),u?(0,X.jsx)(`p`,{role:`status`,children:r?`已回复,原会话将继续。`:`Answer sent. The original conversation will continue.`}):(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),m()},children:[(0,X.jsxs)(`label`,{children:[r?`你的答复`:`Your answer`,(0,X.jsx)(`textarea`,{value:i,maxLength:8e3,disabled:n||c,onChange:e=>a(e.target.value)})]}),(0,X.jsx)(`button`,{type:`submit`,className:`btn`,disabled:n||c||!i.trim()||t.status===`closed`,children:r?`回复并继续`:`Answer & continue`}),o&&(0,X.jsx)(`p`,{role:`alert`,children:o})]})]})}function _e({delivery:e,reviews:t,base:n,roomId:r,conversationId:i,bots:a=[],disabled:o,readOnly:s=!1,zh:c}){let[l,u]=(0,J.useState)(null),[d,f]=(0,J.useState)(null),[p,m]=(0,J.useState)([]);(0,J.useEffect)(()=>{m([])},[d?.id,d?.verification?.digest]);let[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(!1),[y,b]=(0,J.useState)(``),x=(0,J.useRef)(null),S=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>x.current?.abort(),[]),(0,J.useEffect)(()=>{o&&x.current?.abort()},[o]);let C=[...t,...l?[l]:[]].filter(t=>ce(e,t)),w=d?.deliveryId===e.id&&d.status===`verified`&&!!d.verification?.digest&&se(e.artifactRef,d.artifactRef),T=Array.isArray(e.acceptanceCriteria)&&e.acceptanceCriteria.every((e,t)=>p[t]?.met&&p[t]?.evidence.trim()),E=!e.artifactRef||w&&T,D=C.sort((e,t)=>t.createdAt-e.createdAt)[0];async function O(t){if(s||o||x.current||!h.trim()||t===`accepted`&&!E)return;let r=e.artifactRef?{artifactDigest:e.artifactRef.artifactDigest,...t===`accepted`?{integrationId:d.id,verificationDigest:d.verification.digest,criteriaResults:e.acceptanceCriteria.map((e,t)=>({criterionIndex:t,verdict:`met`,evidence:p[t].evidence.trim()}))}:{}}:{commit:e.commit},i=JSON.stringify([e.id,r,t,h.trim()]);S.current?.fingerprint!==i&&(S.current={fingerprint:i,key:L()});let a=new AbortController;x.current=a,v(!0),b(``);try{let i=await pe(`${n}/reviews`,a.signal,{deliveryId:e.id,...r,verdict:t,summary:h.trim(),idempotencyKey:S.current.key});if(a.signal.aborted)return;u(i.review),g(``),S.current=null}catch(e){a.signal.aborted||b(e instanceof Error?e.message:String(e))}finally{x.current===a&&(x.current=null,v(!1))}}return(0,X.jsxs)(`article`,{className:`gd-delivery`,children:[(0,X.jsx)(`p`,{className:`gd-status`,role:`status`,children:D?D.verdict===`accepted`?c?`验收通过`:`Accepted`:c?`需返工`:`Changes requested`:c?`已交付 · 待验收`:`Delivered · Awaiting review`}),(0,X.jsxs)(`dl`,{children:[(0,X.jsx)(`dt`,{children:c?`交付版本 ID`:`Delivery version ID`}),(0,X.jsx)(`dd`,{children:e.id}),(0,X.jsx)(`dt`,{children:c?`仓库`:`Repository`}),(0,X.jsx)(`dd`,{children:e.repository}),e.commit&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:`Commit SHA`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`code`,{children:e.commit})})]}),e.artifactRef&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:c?`产物`:`Artifact`}),(0,X.jsx)(`dd`,{children:e.artifactRef.artifactId}),(0,X.jsx)(`dt`,{children:c?`源码任务`:`Source task`}),(0,X.jsx)(`dd`,{children:e.artifactRef.artifactTaskId}),(0,X.jsx)(`dt`,{children:c?`内容摘要`:`Content digest`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`code`,{children:e.artifactRef.artifactDigest})}),(0,X.jsx)(`dt`,{children:c?`文件树版本`:`File tree version`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`code`,{children:e.artifactRef.outputTree})})]}),(0,X.jsx)(`dt`,{children:c?`基线 SHA`:`Base SHA`}),(0,X.jsx)(`dd`,{children:(0,X.jsx)(`code`,{children:e.baseCommit})}),e.branch&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`dt`,{children:c?`分支`:`Branch`}),(0,X.jsx)(`dd`,{children:e.branch})]}),(0,X.jsx)(`dt`,{children:c?`交付摘要`:`Summary`}),(0,X.jsx)(`dd`,{children:e.summary}),(0,X.jsx)(`dt`,{children:c?`限制与未完成项`:`Limitations`}),(0,X.jsx)(`dd`,{children:e.limitations.length?e.limitations.join(`
|
|
3
3
|
`):c?`Bot 未报告限制`:`No limitations reported by Bot`})]}),(0,X.jsx)(`p`,{children:c?`检查来源:Bot 自报,未经宿主或 CI 验证。`:`Checks source: Bot self-report; not verified by host or CI.`}),e.checks.length?(0,X.jsx)(`ul`,{children:e.checks.map((e,t)=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`code`,{children:e.command}),` · `,e.status,` · `,e.result,e.exitCode!==void 0&&` (exit ${e.exitCode})`]},t))}):(0,X.jsx)(`p`,{children:c?`Bot 未报告检查`:`No checks reported by Bot`}),D&&(0,X.jsxs)(`p`,{children:[c?`验收意见`:`Review`,` (`,D.reviewer.type===`human`?c?`人工`:`Human`:`Bot`,`) ·`,` `,D.summary]}),!s&&(0,X.jsxs)(`form`,{onSubmit:e=>e.preventDefault(),children:[(0,X.jsxs)(`label`,{children:[c?`人工验收意见(对应以上交付版本)`:`Human review (for the delivery version above)`,(0,X.jsx)(`textarea`,{value:h,onChange:e=>g(e.target.value),disabled:o||_,rows:2,required:!0})]}),e.artifactRef&&(0,X.jsxs)(`fieldset`,{disabled:o||_||!w,children:[(0,X.jsx)(`legend`,{children:c?`逐项验收`:`Acceptance criteria`}),(0,X.jsx)(`p`,{children:w?(c?`对应验证:`:`Reviewing verification: `)+d.id:c?`请先展开验证与合并,完成验证后填写验收证据。`:`Open Verify & merge and complete verification before entering acceptance evidence.`}),e.acceptanceCriteria?.map((e,t)=>(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:p[t]?.met??!1,onChange:e=>m(n=>{let r=[...n];return r[t]={evidence:n[t]?.evidence??``,met:e.target.checked},r})}),e]}),(0,X.jsxs)(`label`,{children:[c?`验收证据`:`Evidence`,(0,X.jsx)(`textarea`,{value:p[t]?.evidence??``,maxLength:2e3,onChange:e=>m(n=>{let r=[...n];return r[t]={met:n[t]?.met??!1,evidence:e.target.value},r})})]})]},t))]}),(0,X.jsxs)(`div`,{className:`gd-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||_||!h.trim()||!E,onClick:()=>void O(`accepted`),children:c?`验收通过`:`Accept delivery`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:o||_||!h.trim(),onClick:()=>void O(`changes_requested`),children:c?`需返工`:`Request changes`})]}),_&&(0,X.jsx)(`p`,{role:`status`,children:c?`提交中…`:`Submitting…`}),y&&(0,X.jsx)(`p`,{role:`alert`,children:y})]}),!s&&r&&i&&(0,X.jsx)(fe,{roomId:r,conversationId:i,delivery:e,review:D,onIntegrationChange:f,bots:a,disabled:o,zh:c},`${r}:${i}:${e.id}`)]})}function ve({roomId:e,disabled:t,refreshKey:n=0,connected:i=!1}){let{locale:s}=a(),c=D(s),[l,u]=(0,J.useState)([]),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(0),h=(0,J.useRef)(null);(0,J.useEffect)(()=>()=>{h.current?.abort(),h.current=null},[e,t]);let g=r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/interactions`));(0,J.useEffect)(()=>{if(f(``),t){u([]);return}let n=new AbortController,r=!1;async function a(){if(!(r||document.visibilityState===`hidden`)){r=!0;try{let t=await fetch(g,{credentials:`same-origin`,signal:n.signal}),r=await t.json();if(!t.ok)throw Error(r.error||String(t.status));n.signal.aborted||(u(Array.isArray(r.interactions)?r.interactions.filter(t=>t&&typeof t.id==`string`&&t.roomId===e&&[`question`,`approval`].includes(t.kind)):[]),f(``))}catch(e){n.signal.aborted||f(String(e))}finally{r=!1}}}a();let o=i?void 0:setInterval(()=>void a(),2e3),s=()=>{document.visibilityState!==`hidden`&&a()};return document.addEventListener(`visibilitychange`,s),()=>{n.abort(),clearInterval(o),document.removeEventListener(`visibilitychange`,s)}},[g,t,p,n,i]),(0,J.useEffect)(()=>{u([])},[e]);async function _(e,t){h.current?.abort();let n=new AbortController;h.current=n;try{let r=await fetch(g,{method:`POST`,credentials:`same-origin`,signal:AbortSignal.any([n.signal,AbortSignal.timeout(15e3)]),headers:{"Content-Type":`application/json`},body:JSON.stringify({taskId:e.taskId,attemptId:e.attemptId,interactionId:e.id,...t})}),i=await r.json();if(!r.ok)throw Error(i.error||String(r.status));n.signal.aborted||m(e=>e+1)}finally{h.current===n&&(h.current=null)}}return!l.length&&!d?null:(0,X.jsxs)(`div`,{className:`gd-content dg-native-interactions-wrap`,children:[d&&(0,X.jsx)(`p`,{role:`alert`,children:d}),l.map(t=>(0,X.jsx)(ye,{item:t,zh:c,answer:e=>_(t,e)},`${e}:${t.id}`))]})}function ye({item:e,zh:t,answer:n}){let[r,i]=(0,J.useState)({}),[a,o]=(0,J.useState)(!1),[s,c]=(0,J.useState)(``);async function l(e){o(!0),c(``);try{await n(e)}catch(e){c(String(e)),o(!1)}}let u=(e.questions??[]).filter(e=>!e.dependsOn||r[e.dependsOn.questionId]&&(!e.dependsOn.value||[e.dependsOn.value].flat().some(t=>r[e.dependsOn.questionId].selected.includes(t)))),d=u.every(e=>r[e.id]?.selected.length||r[e.id]?.custom?.trim());return(0,X.jsxs)(`section`,{className:`gd-card`,children:[(0,X.jsxs)(`strong`,{children:[e.kind===`approval`?t?`工具审批 · 仅本次`:`Tool approval · once`:t?`模型提问`:`Model question`,` `,`· `,e.botId]}),e.deadline&&(0,X.jsxs)(`p`,{children:[t?`截止时间:`:`Deadline: `,new Date(e.deadline).toLocaleString()]}),e.kind===`approval`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{children:e.toolName}),(0,X.jsx)(`pre`,{children:e.paramsPreview}),(0,X.jsx)(`p`,{children:e.reason}),(0,X.jsx)(`button`,{className:`btn`,disabled:a,onClick:()=>void l({decision:`approve`}),children:t?`批准本次`:`Approve once`}),(0,X.jsx)(`button`,{className:`btn`,disabled:a,onClick:()=>void l({decision:`deny`}),children:t?`拒绝`:`Deny`})]}):(0,X.jsxs)(`form`,{onSubmit:e=>{e.preventDefault(),d&&l({answers:u.map(e=>r[e.id]??{id:e.id,selected:[]})})},children:[u.map(t=>{let n=r[t.id]??{id:t.id,selected:[]},o=t.optionsMap&&t.dependsOn?t.optionsMap[r[t.dependsOn.questionId]?.selected[0]]??t.options:t.options;return(0,X.jsxs)(`fieldset`,{disabled:a,children:[(0,X.jsx)(`legend`,{children:t.question}),t.detail&&(0,X.jsx)(`p`,{children:t.detail}),o?.map(r=>(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:t.multiSelect?`checkbox`:`radio`,name:`${e.id}:${t.id}`,checked:n.selected.includes(r.label),onChange:e=>i(i=>({...i,[t.id]:{...n,selected:t.multiSelect?e.target.checked?[...n.selected,r.label]:n.selected.filter(e=>e!==r.label):[r.label]}}))}),r.label,r.description&&` · ${r.description}`]},r.label)),(0,X.jsx)(`textarea`,{"aria-label":t.question,maxLength:4e3,value:n.custom??``,onChange:e=>i(r=>({...r,[t.id]:{...n,custom:e.target.value}}))})]},t.id)}),(0,X.jsx)(`button`,{type:`submit`,className:`btn`,disabled:a||!d,children:t?`提交回答`:`Submit answer`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:a,onClick:()=>void l({answers:[],cancelled:!0}),children:t?`取消问卷`:`Cancel question`})]}),s&&(0,X.jsx)(`p`,{role:`alert`,children:s})]})}function be(e){if(!Number.isFinite(e)||e<=0)return`0 B`;let t=[`B`,`KiB`,`MiB`,`GiB`],n=0,r=e;for(;r>=1024&&n<t.length-1;)r/=1024,n++;return`${r.toFixed(n===0?0:1)} ${t[n]}`}async function xe(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:t?AbortSignal.any([t,AbortSignal.timeout(15e3)]):AbortSignal.timeout(15e3),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),a=await i.json().catch(()=>({}));if(!i.ok)throw Error(a.error||String(i.status));return a}function Se({roomId:e,bots:t=[],disabled:n=!1}){let{locale:r}=a(),i=D(r),[o,s]=(0,J.useState)([]),[c,l]=(0,J.useState)({}),[u,d]=(0,J.useState)(!1),[f,p]=(0,J.useState)(``),[m,h]=(0,J.useState)(``),[g,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(``),[S,C]=(0,J.useState)(``),[w,T]=(0,J.useState)(!0),[E,O]=(0,J.useState)(!1),k=(0,J.useRef)(0),A=(0,J.useRef)(e);A.current=e;let j=(0,J.useRef)(new Set),M=(0,J.useRef)(null);function N(){let e=new AbortController;return j.current.add(e),e}let P=(0,J.useRef)(new Map);(0,J.useEffect)(()=>{P.current=new Map(t.map(e=>[e.id,e.name||e.id])),y(e=>t.some(t=>t.id===e)?e:t[0]?.id??``),x(e=>t.some(t=>t.id===e)?e:t[1]?.id??``)},[t,e]);function F(e){return P.current.get(e)||e}(0,J.useEffect)(()=>(k.current++,M.current=null,O(!1),d(!1),s([]),h(``),p(``),l({}),_(!1),C(``),()=>{k.current++;for(let e of j.current)e.abort();j.current.clear()}),[e]),(0,J.useEffect)(()=>{if(!e)return;let t=k.current,n,r=null,i=!1;async function a(){if(!(i||t!==k.current)){if(document.visibilityState===`hidden`){n=setTimeout(a,4e3);return}r=new AbortController;try{let n=await xe(`rooms/${encodeURIComponent(e)}/transfers`,r.signal);!i&&t===k.current&&A.current===e&&Array.isArray(n?.transfers)&&s(n.transfers)}catch{}finally{if(!i&&t===k.current){let e=o.some(e=>[`queued`,`staging`,`cancelling`,`applying`].includes(e.status));n=setTimeout(a,e?1500:4e3)}}}}return a(),()=>{i=!0,clearTimeout(n),r?.abort()}},[e,o.length]);let I=(e,t)=>{l(n=>{let r=new Set(n[e]||[]);return r.has(t)?r.delete(t):r.add(t),{...n,[e]:r}})},L=async t=>{if(t.preventDefault(),!v||!b||!S.trim()||E)return;if(v===b){h(i?`源机器人与目标机器人不能相同`:`Source and target bots must be different`);return}let n=k.current,r=e,a=N();O(!0),h(``),p(i?`正在创建并启动文件传输...`:`Initiating chunked file transfer...`);try{let t=S.split(`
|
|
4
|
-
`).map(e=>e.trim()).filter(Boolean),o=JSON.stringify([e,v,b,t,w]);M.current?.fingerprint!==o&&(M.current={fingerprint:o,key:crypto.randomUUID()});let c=await xe(`rooms/${encodeURIComponent(e)}/transfers/start`,a.signal,{idempotencyKey:M.current.key,sourceBotId:v,targetBotId:b,paths:t,recursive:w});if(n!==k.current||r!==A.current)return;p(i?`传输任务已成功启动 (ID: ${c.transferId?.slice(0,8)??``}),正在后台分块传输中。`:`Transfer started (ID: ${c.transferId?.slice(0,8)??``}), streaming chunks in background.`),_(!1),C(``),M.current=null;let l=await xe(`rooms/${encodeURIComponent(e)}/transfers`,a.signal);n===k.current&&r===A.current&&Array.isArray(l?.transfers)&&s(l.transfers)}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(a),n===k.current&&r===A.current&&O(!1)}},R=async t=>{let n=t.preview||(t.files?{id:t.transferId,revision:t.revision||``,files:t.files}:void 0);if(!n||u)return;let r=k.current,a=e,o=N();d(!0),h(``),p(i?`正在导入文件变更...`:`Applying file changes...`);try{let l=Array.from(c[t.transferId]||[]),u=await xe(`rooms/${encodeURIComponent(e)}/transfers/${encodeURIComponent(t.transferId)}/apply`,o.signal,{revision:n.revision,overwritePaths:l});if(r!==k.current||a!==A.current)return;p(i?`导入成功:已应用 ${u.applied?.length??0} 个文件,未变 ${u.unchanged?.length??0} 个`:`Apply successful: applied ${u.applied?.length??0}, unchanged ${u.unchanged?.length??0}`),s(e=>e.map(e=>e.transferId===t.transferId?{...e,status:`applied`}:e))}catch(e){r===k.current&&a===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(o),r===k.current&&a===A.current&&d(!1)}},z=async t=>{let n=k.current,r=e,a=N();try{if(await xe(`rooms/${encodeURIComponent(e)}/transfers/${encodeURIComponent(t.transferId)}/abort`,a.signal,{}),n!==k.current||r!==A.current)return;s(e=>e.map(e=>e.transferId===t.transferId?{...e,status:`cancelled`}:e)),p(i?`传输已取消,暂存文件与配额已物理释放`:`Transfer aborted; staged quota freed`)}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(a)}},B=async t=>{let n=k.current,r=e,i=N();try{let e=await xe(`rooms/${encodeURIComponent(r)}/transfers/${encodeURIComponent(t.transferId)}/resume`,i.signal,{manifestHash:t.manifestHash,sourceBotRevision:t.sourceBotRevision,targetBotRevision:t.targetBotRevision});n===k.current&&r===A.current&&s(n=>n.map(n=>n.transferId===t.transferId?e:n))}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(i)}},V=o.filter(e=>[`queued`,`staging`,`cancelling`].includes(e.status)).length,H=o.filter(e=>e.status===`staged`||e.status===`ready`).length;return(0,X.jsxs)(`details`,{className:`dft-panel`,open:o.length>0,children:[(0,X.jsxs)(`summary`,{className:`dft-summary`,children:[(0,X.jsx)(`span`,{className:`dft-title-icon`,children:`📦`}),(0,X.jsx)(`span`,{children:i?`跨机大文件传输与断点续传`:`Cross-Device Chunked File Transfers`}),o.length>0&&(0,X.jsx)(`span`,{className:`dft-badge`,children:V>0?i?`${V} 个传输中`:`${V} streaming`:H>0?i?`${H} 个待导入`:`${H} staged`:`${o.length}`})]}),(0,X.jsxs)(`div`,{className:`dft-content`,children:[m&&(0,X.jsx)(`div`,{className:`dft-alert dft-alert-error`,role:`alert`,children:m}),f&&(0,X.jsx)(`div`,{className:`dft-alert dft-alert-info`,children:f}),(0,X.jsx)(`div`,{className:`dft-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn dft-btn-toggle`,onClick:()=>_(e=>!e),disabled:n||t.length<2,children:g?i?`收起传输表单`:`Close Transfer Form`:i?`+ 发起新文件/目录传输`:`+ New File/Directory Transfer`})}),g&&(0,X.jsxs)(`form`,{className:`dft-start-form`,onSubmit:L,children:[(0,X.jsxs)(`div`,{className:`dft-form-row`,children:[(0,X.jsxs)(`label`,{className:`dft-form-label`,children:[(0,X.jsx)(`span`,{children:i?`源机器人 (发送端)`:`Source Bot (Sender)`}),(0,X.jsx)(`select`,{className:`dft-select`,value:v,onChange:e=>y(e.target.value),disabled:n||E,children:t.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name||e.id,` (`,e.id.slice(0,8),`)`]},e.id))})]}),(0,X.jsxs)(`label`,{className:`dft-form-label`,children:[(0,X.jsx)(`span`,{children:i?`目标机器人 (接收端)`:`Target Bot (Receiver)`}),(0,X.jsx)(`select`,{className:`dft-select`,value:b,onChange:e=>x(e.target.value),disabled:n||E,children:t.filter(e=>e.id!==v).map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name||e.id,` (`,e.id.slice(0,8),`)`]},e.id))})]})]}),(0,X.jsx)(`div`,{className:`dft-form-row`,children:(0,X.jsxs)(`label`,{className:`dft-form-label full-width`,children:[(0,X.jsx)(`span`,{children:i?`相对路径(文件或目录,每行一个)`:`Project-relative paths (one per line)`}),(0,X.jsx)(`textarea`,{className:`dft-textarea`,rows:2,placeholder:i?`如: src/ 或 large-asset.bin`:`e.g. src/ or data/model.weights`,value:S,onChange:e=>C(e.target.value),disabled:n||E})]})}),(0,X.jsxs)(`div`,{className:`dft-form-footer`,children:[(0,X.jsxs)(`label`,{className:`dft-checkbox-label`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),disabled:n||E}),(0,X.jsx)(`span`,{children:i?`递归包含子目录 (recursive)`:`Recursive directory traversal`})]}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary dft-btn-submit`,disabled:n||E||!S.trim()||v===b,children:E?i?`启动中...`:`Starting...`:i?`开始分块传输`:`Start Transfer`})]})]}),o.length===0?(0,X.jsxs)(`div`,{className:`dft-empty`,children:[(0,X.jsx)(`p`,{children:i?`当前群暂无文件传输记录。`:`No active file transfers in this room.`}),(0,X.jsx)(`span`,{className:`dft-hint`,children:i?`支持突破 8MiB 限制的大文件及 >128 文件的目录分块传输。发起后将在此实时展示进度与断点续传状态。`:`Supports >8MiB files and 128+ file directories. Live progress, chunk checksums and resume controls appear here.`})]}):(0,X.jsx)(`div`,{className:`dft-transfers-list`,children:o.map(e=>{let t=Math.min(100,Math.max(0,e.percent??0)),r=e.preview?.files||e.files||[],a=c[e.transferId]||new Set;return(0,X.jsxs)(`div`,{className:`dft-card dft-card-${e.status}`,children:[(0,X.jsxs)(`div`,{className:`dft-card-header`,children:[(0,X.jsxs)(`div`,{className:`dft-route`,children:[(0,X.jsx)(`span`,{className:`dft-bot-name`,children:F(e.sourceBotId)}),(0,X.jsx)(`span`,{className:`dft-arrow`,children:`➔`}),(0,X.jsx)(`span`,{className:`dft-bot-name`,children:F(e.targetBotId)}),(0,X.jsx)(`span`,{className:`dft-id-badge`,title:e.transferId,children:e.transferId.slice(0,8)})]}),(0,X.jsxs)(`span`,{className:`dft-status-tag dft-tag-${e.status}`,children:[e.status===`staging`&&(i?`分块传输中`:`Streaming`),(e.status===`staged`||e.status===`ready`)&&(i?`待确认导入`:`Ready`),e.status===`queued`&&(i?`排队中`:`Queued`),e.status===`interrupted`&&(i?`已中断`:`Interrupted`),e.status===`cancelling`&&(i?`取消中`:`Cancelling`),e.status===`applying`&&(i?`导入中`:`Applying`),e.status===`applied`&&(i?`已导入`:`Applied`),e.status===`cancelled`&&(i?`已取消`:`Cancelled`),e.status===`failed`&&(i?`失败`:`Failed`)]})]}),(0,X.jsxs)(`div`,{className:`dft-metrics`,children:[(0,X.jsxs)(`span`,{children:[i?`文件: `:`Files: `,(0,X.jsx)(`strong`,{children:e.totalFiles==null?`-`:e.totalFiles})]}),(0,X.jsxs)(`span`,{children:[i?`大小: `:`Size: `,(0,X.jsx)(`strong`,{children:e.totalBytes==null?`-`:be(e.totalBytes)})]}),(0,X.jsxs)(`span`,{children:[i?`分块: `:`Chunks: `,(0,X.jsx)(`strong`,{children:e.totalChunks==null?`-`:`${e.receivedChunks?.length??0} / ${e.totalChunks}`})]})]}),(0,X.jsx)(`div`,{className:`dft-progress-bar-wrap`,children:(0,X.jsx)(`div`,{className:`dft-progress-bar`,style:{width:`${t}%`}})}),(0,X.jsxs)(`div`,{className:`dft-progress-label`,children:[(0,X.jsxs)(`span`,{children:[t,`%`]}),(0,X.jsx)(`span`,{className:`dft-hash-status`,children:e.status===`staged`||e.status===`ready`||e.status===`applied`?i?`✓ SHA256 完整校验通过`:`✓ SHA256 Verified`:e.status===`cancelled`?i?`传输已取消`:`Transfer cancelled`:e.status===`failed`?i?`传输失败`:`Transfer failed`:e.status===`interrupted`?i?`传输已中断`:`Transfer interrupted`:i?`32KiB 有界分块传输与断点校验中`:`32KiB Bounded Chunk Streaming`})]}),e.error&&(0,X.jsx)(`div`,{className:`dft-item-error`,title:e.error,children:e.error}),r.length>0&&(0,X.jsxs)(`div`,{className:`dft-preview-section`,children:[(0,X.jsx)(`div`,{className:`dft-preview-title`,children:i?`变更差异预览:`:`File Changes Preview:`}),(0,X.jsx)(`div`,{className:`dft-files-table`,children:r.map(t=>(0,X.jsxs)(`div`,{className:`dft-file-row dft-file-${t.status}`,children:[(0,X.jsxs)(`span`,{className:`dft-file-status-icon`,children:[t.status===`create`&&`➕`,t.status===`identical`&&`✓`,t.status===`conflict`&&`⚠️`]}),(0,X.jsx)(`span`,{className:`dft-file-path`,title:t.path,children:t.path}),(0,X.jsx)(`span`,{className:`dft-file-size`,children:be(t.size)}),t.status===`conflict`&&(0,X.jsxs)(`label`,{className:`dft-overwrite-toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a.has(t.path),onChange:()=>I(e.transferId,t.path),disabled:n||e.status!==`staged`&&e.status!==`ready`}),(0,X.jsx)(`span`,{children:i?`显式覆盖`:`Overwrite`})]})]},t.path))})]}),(0,X.jsxs)(`div`,{className:`dft-card-actions`,children:[e.status===`interrupted`&&e.manifestHash&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:n,onClick:()=>B(e),children:i?`按原版本续传`:`Resume saved version`}),!e.applyStarted&&[`queued`,`staging`,`ready`,`interrupted`,`failed`].includes(e.status)&&(0,X.jsx)(`button`,{type:`button`,className:`btn dft-btn-abort`,onClick:()=>z(e),disabled:n,children:i?`取消传输`:`Abort Transfer`}),(e.status===`staged`||e.status===`ready`)&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary dft-btn-apply`,onClick:()=>R(e),disabled:n||u,children:u?i?`导入中...`:`Applying...`:i?`确认导入变更 (Apply)`:`Confirm Apply`})]})]},e.transferId)})})]})]})}async function Ce(e,t){let n=await fetch(r(o(`/api/device-center/${e}`)),{method:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(15e3)])}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error||`HTTP ${n.status}`);return i}function we({roomId:e,taskId:t,onClose:n}){let{locale:r}=a(),i=D(r),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!0),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(`journal`),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(``),[E,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,M]=(0,J.useState)(!1),[N,P]=(0,J.useState)(!1),F=(0,J.useRef)(null),I=(0,J.useRef)(null),L=(0,J.useRef)(null),R=(0,J.useRef)(n);R.current=n,(0,J.useEffect)(()=>{let e=e=>{e.key===`Escape`&&R.current()};return window.addEventListener(`keydown`,e),L.current?.focus(),()=>{window.removeEventListener(`keydown`,e)}},[]),(0,J.useEffect)(()=>{F.current?.abort();let n=new AbortController;F.current=n,s(null),l([]),d(null),T(``),C(null),O(!1),A(void 0),P(!1),_(``),y(``),p(!0);async function r(){let[r,a]=await Promise.allSettled([Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`,n.signal),Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/journal?limit=25&direction=forward`,n.signal)]);if(!n.signal.aborted){if(r.status===`fulfilled`){let e=r.value;s(e),e.reportMeta&&C(e.reportMeta)}else _(r.reason?.message||`Failed to load task details`);a.status===`fulfilled`?(l(a.value.items),d(a.value)):y(a.reason?.message||(i?`加载事件流失败`:`Failed to load journal`)),p(!1)}}return r(),()=>{n.abort(),I.current!==null&&(clearTimeout(I.current),I.current=null)}},[e,t]);async function z(){if(!u?.nextCursor||m)return;let n=F.current??new AbortController;h(!0);try{let r=await Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/journal?limit=25&direction=forward&cursor=${encodeURIComponent(u.nextCursor)}`,n.signal);if(n.signal.aborted)return;l(e=>[...e,...r.items]),d(r)}catch(e){n.signal.aborted||y(e?.message||(i?`分页加载日志失败`:`Failed to load more journal events`))}finally{n.signal.aborted||h(!1)}}async function B(n){let r=F.current??new AbortController;M(!0);try{let i=n===void 0?`?offset=0&limit=262144`:`?offset=${n}&limit=262144`,a=await Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/report${i}`,r.signal);if(r.signal.aborted)return;C(a.meta);let o=a.text??``;T(e=>n===void 0||n===0?o:e+o),O(!!a.hasMore),A(a.nextOffset??void 0)}catch(e){r.signal.aborted||_(i?`加载报告分片失败: ${e.message}`:`Failed to load report slice: ${e.message}`)}finally{r.signal.aborted||M(!1)}}function V(){w&&navigator.clipboard.writeText(w).then(()=>{P(!0),I.current!==null&&clearTimeout(I.current),I.current=window.setTimeout(()=>{P(!1),I.current=null},2e3)}).catch(()=>{_(i?`复制报告失败,请手动选择复制`:`Failed to copy report to clipboard`)})}let H=c.filter(e=>e.toolName||e.type.startsWith(`tool_`)||e.parametersPreview&&Object.keys(e.parametersPreview).length>0),U=o?.task;function ee(e){let t=e||`queued`,n={queued:{zh:`排队中`,en:`Queued`,cls:`gtd-badge-queued`},running:{zh:`运行中`,en:`Running`,cls:`gtd-badge-running`},completed:{zh:`已完成`,en:`Completed`,cls:`gtd-badge-completed`},failed:{zh:`失败`,en:`Failed`,cls:`gtd-badge-failed`},interrupted:{zh:`已中断`,en:`Interrupted`,cls:`gtd-badge-interrupted`}}[t]||{zh:t,en:t,cls:`gtd-badge-queued`};return(0,X.jsx)(`span`,{className:`gtd-badge ${n.cls}`,children:i?n.zh:n.en})}return(0,X.jsx)(`div`,{className:`gtd-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":i?`任务详情`:`Task Details`,children:(0,X.jsxs)(`div`,{className:`gtd-panel`,ref:L,tabIndex:-1,children:[(0,X.jsxs)(`div`,{className:`gtd-header`,children:[(0,X.jsxs)(`div`,{className:`gtd-header-title`,children:[(0,X.jsx)(`h3`,{children:i?`群任务详情与操作审计`:`Group Task Details & Audit Log`}),U&&(0,X.jsxs)(`span`,{className:`gtd-task-id`,children:[`#`,U.id.slice(0,8)]}),U&&ee(U.status)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn gtd-close-btn gtd-close`,onClick:n,children:`✕`})]}),g&&(0,X.jsx)(`div`,{className:`gtd-error-banner`,role:`alert`,children:g}),f?(0,X.jsx)(`div`,{className:`gtd-loading`,children:i?`加载任务详情中...`:`Loading task details...`}):(0,X.jsxs)(`div`,{className:`gtd-body`,children:[U&&(0,X.jsxs)(`div`,{className:`gtd-overview-card`,children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`目标内容:`:`Objective:`}),(0,X.jsx)(`span`,{className:`gtd-value gtd-task-text`,children:U.text})]}),(0,X.jsxs)(`div`,{className:`gtd-meta-row`,children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`执行 Bot:`:`Bot:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:U.botName||U.botId})]}),U.deviceName&&(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`运行设备:`:`Device:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:U.deviceName})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`创建时间:`:`Created:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:new Date(U.createdAt).toLocaleTimeString()})]})]}),U.queuedReason&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-info`,children:[(0,X.jsx)(`strong`,{children:i?`排队原因:`:`Queued Reason:`}),` `,U.queuedReason]}),U.interruptedReason&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[(0,X.jsx)(`strong`,{children:i?`中断原因:`:`Interruption Reason:`}),` `,U.interruptedReason]})]}),o&&o.interactions.length>0&&(0,X.jsxs)(`div`,{className:`gtd-section`,children:[(0,X.jsx)(`h4`,{children:i?`关联人工审批与问卷`:`Associated Human Interactions`}),(0,X.jsx)(`div`,{className:`gtd-interaction-list`,children:o.interactions.map(e=>(0,X.jsxs)(`div`,{className:`gtd-interaction-item`,children:[(0,X.jsxs)(`div`,{className:`gtd-interaction-header`,children:[(0,X.jsx)(`span`,{className:`gtd-interaction-kind`,children:e.kind}),(0,X.jsx)(`span`,{className:e.resolved?`gtd-badge-completed`:`gtd-badge-queued`,children:e.resolved?i?`已裁决`:`Resolved`:i?`待处理`:`Pending`})]}),e.question&&(0,X.jsx)(`div`,{className:`gtd-interaction-q`,children:e.question}),e.decision&&(0,X.jsxs)(`div`,{className:`gtd-interaction-ans`,children:[i?`裁决结论: `:`Decision: `,` `,e.decision]})]},e.id))})]}),o&&o.deliveries.length>0&&(0,X.jsxs)(`div`,{className:`gtd-section`,children:[(0,X.jsx)(`h4`,{children:i?`关联代码交付`:`Associated Code Deliveries`}),(0,X.jsx)(`div`,{className:`gtd-delivery-list`,children:o.deliveries.map(e=>(0,X.jsxs)(`div`,{className:`gtd-delivery-item`,children:[(0,X.jsxs)(`div`,{className:`gtd-delivery-header`,children:[e.commit&&(0,X.jsx)(`span`,{className:`gtd-commit-sha`,children:e.commit.slice(0,8)}),e.branch&&(0,X.jsx)(`span`,{className:`gtd-branch-chip`,children:e.branch}),(0,X.jsx)(`span`,{className:e.reportedCheckCount===0?`gtd-badge-queued`:e.passed?`gtd-badge-completed`:`gtd-badge-failed`,children:e.reportedCheckCount===0?i?`未自报检查`:`No reported checks`:e.passed?i?`自报检查通过`:`Reported checks passed`:i?`自报检查未通过`:`Reported checks not passed`})]}),(0,X.jsx)(`div`,{className:`gtd-delivery-summary`,children:e.summary}),e.artifactRef&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`交付版本 ID:`:`Delivery version ID:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.id})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`产物:`:`Artifact:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactId})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`源码任务:`:`Source task:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactTaskId})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`内容摘要:`:`Content digest:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactDigest})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`文件树版本:`:`File tree version:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.outputTree})]})]})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`gtd-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`gtd-tab ${b===`journal`?`active`:``}`,onClick:()=>x(`journal`),children:[i?`事件与审计流`:`Journal Events`,` (`,c.length,`)`]}),(0,X.jsxs)(`button`,{type:`button`,className:`gtd-tab ${b===`tools`?`active`:``}`,onClick:()=>x(`tools`),children:[i?`工具调用卡片`:`Tool Lifecycles`,` (`,H.length,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`gtd-tab ${b===`report`?`active`:``}`,onClick:()=>{x(`report`),w||(M(!0),B())},children:i?`任务完整报告`:`Full Report Log`})]}),b===`journal`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[u?.truncated&&(0,X.jsxs)(`div`,{className:`gtd-truncation-notice`,children:[`⚠️`,` `,i?`由于日志保留配额,最早的 ${u.droppedCount} 条事件已自动淘汰。系统明确标记并不伪装历史完整。`:`The earliest ${u.droppedCount} events were pruned due to journal retention quota. History is not disguised as complete.`]}),u?.cursorExpired&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`游标所在的分段已淘汰,显示当前保留的最旧事件。`:`The requested cursor was pruned from disk; showing oldest retained segments.`}),u?.corrupted&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`部分分段可能存在损坏行,已保留损坏证据。`:`Corrupted lines detected and flagged.`}),v&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,role:`alert`,children:v}),u?.journalUnavailable&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`事件日志写入失败或被降级,审计流可能不完整。`:`Journal persistence failed or degraded; the audit trail may be incomplete.`}),c.length===0?(0,X.jsx)(`div`,{className:`gtd-empty`,children:i?`暂无事件记录`:`No journal events recorded.`}):(0,X.jsx)(`div`,{className:`gtd-journal-list`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`gtd-journal-entry`,children:[(0,X.jsxs)(`div`,{className:`gtd-entry-meta`,children:[(0,X.jsxs)(`span`,{className:`gtd-entry-seq`,children:[`#`,e.sequence]}),(0,X.jsx)(`span`,{className:`gtd-entry-type`,children:e.type}),(0,X.jsx)(`span`,{className:`gtd-entry-time`,children:new Date(e.timestamp).toLocaleTimeString()})]}),e.summary&&(0,X.jsx)(`div`,{className:`gtd-entry-summary`,children:e.summary}),e.output&&(0,X.jsx)(`pre`,{className:`gtd-entry-output`,children:e.output}),e.reason&&(0,X.jsx)(`div`,{className:`gtd-entry-reason`,children:e.reason})]},e.id))}),u?.hasMore&&(0,X.jsx)(`div`,{className:`gtd-load-more-row`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn gtd-load-more-btn`,disabled:m,onClick:z,children:m?i?`加载中...`:`Loading...`:i?`加载更多历史事件`:`Load more journal events`})})]}),b===`tools`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[v&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,role:`alert`,children:v}),H.length===0?(0,X.jsx)(`div`,{className:`gtd-empty`,children:i?`本任务暂无工具调用记录`:`No tool invocations recorded.`}):(0,X.jsx)(`div`,{className:`gtd-tool-cards`,children:H.map(e=>(0,X.jsxs)(`div`,{className:`gtd-tool-card`,children:[(0,X.jsxs)(`div`,{className:`gtd-tool-card-head`,children:[(0,X.jsx)(`strong`,{children:e.toolName||`tool`}),(0,X.jsx)(`span`,{className:`gtd-tool-phase`,children:e.type})]}),e.parametersPreview&&(0,X.jsxs)(`div`,{className:`gtd-tool-params`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`安全参数摘要:`:`Parameters:`}),(0,X.jsx)(`pre`,{children:JSON.stringify(e.parametersPreview,null,2)})]}),e.output&&(0,X.jsxs)(`div`,{className:`gtd-tool-output`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`增量安全输出:`:`Output Snippet:`}),(0,X.jsx)(`pre`,{children:e.output})]})]},e.id))})]}),b===`report`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[S&&(0,X.jsxs)(`div`,{className:`gtd-report-meta-box`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`存储位置:`:`Storage:`}),` `,(0,X.jsxs)(`code`,{children:[S.storageLocation.role,`::`,S.storageLocation.reportRef]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`报告总大小:`:`Total Size:`}),` `,(0,X.jsxs)(`span`,{children:[S.totalBytes,` bytes`]})]}),S.sha256&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`完整性 SHA256:`:`SHA256:`}),` `,(0,X.jsxs)(`code`,{children:[S.sha256.slice(0,16),`...`]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`当前已加载:`:`Loaded Size:`}),` `,(0,X.jsxs)(`span`,{children:[new TextEncoder().encode(w).length,` bytes`]})]}),S.quotaExceeded&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[`⚠️`,` `,i?`报告超过配额硬限制 (${S.quotaLimit} bytes),系统明确拒绝接收超额部分,绝不伪装完整。`:`Report exceeded quota limit (${S.quotaLimit} bytes) and was rejected without partial truncation disguise.`]}),S.uploadPending&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-info`,children:[`⏳ `,i?`完整报告正在由执行设备分块同步中...`:`Full report chunk sync in progress...`]}),S.missing&&!S.uploadPending&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[`⚠️ `,i?`执行设备尚未上传完整报告原文。`:`Full report has not yet been uploaded by device.`]})]}),(0,X.jsxs)(`div`,{className:`gtd-report-actions`,children:[E&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:j,onClick:()=>B(k),children:j?i?`加载中...`:`Loading...`:i?`加载更多报告内容`:`Load more report`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:j||!w,onClick:V,children:N?i?`已复制`:`Copied!`:i?`复制报告全文`:`Copy Report`})]}),j&&!w?(0,X.jsx)(`div`,{className:`gtd-loading`,children:i?`正在读取报告文件...`:`Loading report file...`}):(0,X.jsx)(`pre`,{className:`gtd-report-viewer gtd-report-text`,children:w})]})]})]})})}var Te={zh:{planTitle:`群任务计划`,planDraft:`计划草稿编制中`,planReady:`计划已就绪(需确认后开始)`,planApproved:`计划已批准实施`,startPlan:`开始实施`,startingPlan:`正在启动…`,canvasTitle:`关联画布工作流`,canvasManualNote:`画布已就绪。引用不会自动运行,点击按钮显式启动。`,launchCanvas:`启动画布`,launchingCanvas:`正在启动画布…`,botPresetTitle:`Bot 运行快照`,lockedSnapshot:`在途任务快照已锁定(v{rev})`,toolsCount:`已授权 {count} 个工具`,isolatedNote:`独立隔离运行,未共享主会话私有配置`,applyPreset:`应用最新快照`,applyingPreset:`应用中…`,lockedCannotApply:`在途任务禁止热改预设`},en:{planTitle:`Group Task Plan`,planDraft:`Drafting plan`,planReady:`Plan Ready (Requires confirmation to start)`,planApproved:`Plan approved & executing`,startPlan:`Start Execution`,startingPlan:`Starting…`,canvasTitle:`Linked Canvas Workflow`,canvasManualNote:`Canvas attached. Workflow will not run automatically. Click to launch explicitly.`,launchCanvas:`Launch Canvas`,launchingCanvas:`Launching canvas…`,botPresetTitle:`Bot Preset Snapshot`,lockedSnapshot:`Active task snapshot locked (v{rev})`,toolsCount:`{count} authorized tools`,isolatedNote:`Isolated run, main session private config is not leaked`,applyPreset:`Apply Latest Snapshot`,applyingPreset:`Applying…`,lockedCannotApply:`Active tasks cannot hot-reload presets`}};function Ee({roomId:e,activeTaskId:t,taskSnapshotRevision:n,planState:r,canvasRef:o,botSnapshot:s,onStartPlanExecution:c,onLaunchCanvas:l,onApplyPresetSnapshot:u,uiSlotEntries:d,onUiAction:f,className:m}){let{locale:h}=a(),g=Te[D(h)?`zh`:`en`],v=(0,J.useRef)(e);(0,J.useEffect)(()=>{v.current=e,j(null),x(!1),C(!1),T(!1)},[e]);let[y,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),[k,j]=(0,J.useState)(null);return k||r||o||s||d&&d.length>0?(0,X.jsxs)(`div`,{className:`group-workspace-actions ${m??``}`.trim(),children:[k&&(0,X.jsxs)(`div`,{className:`group-workspace-error-banner`,role:`alert`,children:[(0,X.jsx)(O,{className:`error-icon`}),(0,X.jsx)(`span`,{children:k})]}),r&&(0,X.jsxs)(`div`,{className:`group-workspace-card plan-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(E,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.planTitle}),(0,X.jsxs)(`span`,{className:`plan-badge status-${r.state}`,children:[r.state===`draft`&&g.planDraft,r.state===`ready`&&g.planReady,r.state===`approved`&&g.planApproved]})]}),r.steps&&r.steps.length>0&&(0,X.jsx)(`ul`,{className:`plan-steps-list`,children:r.steps.map(e=>(0,X.jsxs)(`li`,{className:`step-item status-${e.status??`pending`}`,children:[(0,X.jsx)(P,{className:`step-icon`}),(0,X.jsx)(`span`,{className:`step-title`,children:e.title})]},e.id))}),r.state===`ready`&&c&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary start-plan-btn`,onClick:async()=>{if(!t||!r||y||!c)return;let n=ie(r);if(!n.ok){j(n.reason??`Plan is not ready for approval`);return}j(null),x(!0);try{await c(t)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&x(!1)}},disabled:y,children:[(0,X.jsx)(i,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:y?g.startingPlan:g.startPlan})]})})]}),o&&(0,X.jsxs)(`div`,{className:`group-workspace-card canvas-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(b,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.canvasTitle}),(0,X.jsx)(`span`,{className:`canvas-badge`,children:o.title||o.graphId})]}),(0,X.jsx)(`p`,{className:`card-note`,children:g.canvasManualNote}),l&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn launch-canvas-btn`,onClick:async()=>{if(o&&!S&&l&&!ae(o)){j(null),C(!0);try{await l(o.graphId)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&C(!1)}}},disabled:S,children:[(0,X.jsx)(i,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:S?g.launchingCanvas:g.launchCanvas})]})})]}),s&&(0,X.jsxs)(`div`,{className:`group-workspace-card bot-preset-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(A,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.botPresetTitle}),(0,X.jsx)(`span`,{className:`bot-badge`,children:s.name})]}),(0,X.jsxs)(`div`,{className:`bot-snapshot-meta`,children:[(0,X.jsxs)(`span`,{className:`snapshot-rev`,children:[(0,X.jsx)(p,{className:`rev-icon`}),g.lockedSnapshot.replace(`{rev}`,String(s.revision))]}),(0,X.jsx)(`span`,{className:`snapshot-tools`,children:g.toolsCount.replace(`{count}`,String(s.toolWhitelist.length))})]}),(0,X.jsx)(`p`,{className:`card-note-faint`,children:g.isolatedNote}),u&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary apply-preset-btn`,onClick:async()=>{if(s&&!w&&u){if(!q(n,s.revision)){j(g.lockedCannotApply);return}j(null),T(!0);try{let e=re(s,s.botId,s.revision+1);await u(s.botId,e)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&T(!1)}}},disabled:w||!q(n,s.revision),title:q(n,s.revision)?void 0:g.lockedCannotApply,children:[(0,X.jsx)(_,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:w?g.applyingPreset:g.applyPreset})]})})]}),d&&d.length>0&&(0,X.jsxs)(`div`,{className:`group-workspace-card group-slots-card`,children:[(0,X.jsx)(`div`,{className:`card-header`,children:(0,X.jsx)(`span`,{className:`card-title`,children:D(h)?`扩展操作`:`Extensions`})}),(0,X.jsx)(`div`,{className:`card-actions group-slots-actions`,children:d.filter(e=>!e.hidden).map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn secondary group-slot-btn`,onClick:()=>f?.(e),title:e.label,children:e.label},e.id))})]})]}):null}function De({roomId:e,binding:t,onSaved:n}){let i=D(a().locale),s=T(`cwd`),c=(0,J.useRef)(null),l=(0,J.useRef)(null),[u,d]=(0,J.useState)([]),[f,p]=(0,J.useState)(t?.graphId??``),[m,h]=(0,J.useState)(t?.cwd??s),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=new AbortController;l.current=e,x(!1),fetch(r(o(`/api/device-center/chat-status`)),{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok||!t.deviceId)throw Error(t.error??`Local device identity unavailable`);_(t.deviceId)}).catch(t=>{e.signal.aborted||C(String(t.message))});let n=new oe({loadGraphOnConnect:!1});c.current=n;let i=n.subscribe(e=>{e.type===`canvas_list_result`&&d(e.graphs),e.type===`canvas_error`&&e.graphId===t?.graphId&&C(e.message),e.type===`canvas_node_event`&&e.graphId===t?.graphId&&C(`${e.nodeId}: ${e.event}`)}),a=n.subscribeConnection(y);return n.connect(),()=>{e.abort(),i(),a(),n.dispose(),c.current=null}},[t?.graphId,e]),(0,J.useEffect)(()=>{p(t?.graphId??``),h(t?.cwd??s)},[t?.graphId,t?.cwd,s]);let w=!!g&&(!t||t.deviceId===g);async function E(t=!1){let a=l.current;if(a&&!a.signal.aborted){x(!0),C(``);try{let s=u.find(e=>e.id===f);if(!t&&(!s||!m.trim()||!g))throw Error(`Select a local graph and workspace`);let c=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/canvas`)),{method:`POST`,signal:a.signal,headers:{"Content-Type":`application/json`},body:JSON.stringify({binding:t?null:{deviceId:g,graphId:f,cwd:m.trim(),title:s.name}})}),l=await c.json();if(!c.ok)throw Error(l.error??`Canvas binding failed`);if(a.signal.aborted)return;n(),C(i?`群画布引用已保存;点击启动才会执行。`:`Group canvas reference saved. Run explicitly to execute.`)}catch(e){a.signal.aborted||C(e.message)}finally{a.signal.aborted||x(!1)}}}return(0,X.jsxs)(`details`,{className:`group-ecosystem-panel`,children:[(0,X.jsxs)(`summary`,{children:[i?`群画布`:`Group canvas`,t?` · ${t.title}`:``]}),(0,X.jsx)(`p`,{children:i?`引用保存在群组中。运行发生在绑定设备,使用下方工作目录;保存引用不会运行。`:`References are saved with the group. Runs use the bound device and workspace. Saving does not run the graph.`}),t&&(0,X.jsxs)(`p`,{children:[t.deviceId,` · `,t.graphId,` · `,t.cwd]}),!w&&t&&(0,X.jsx)(`p`,{role:`status`,children:i?`此画布属于另一台设备,请在该设备打开群组后运行。可选择本机画布重新绑定。`:`This canvas belongs to another device. Open the group there to run it, or bind a local canvas.`}),(0,X.jsxs)(`label`,{children:[i?`本机工程`:`Local graph`,(0,X.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:i?`选择画布`:`Select canvas`}),u.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsxs)(`label`,{children:[i?`本机工作目录`:`Local workspace`,(0,X.jsx)(`input`,{value:m,onChange:e=>h(e.target.value)})]}),(0,X.jsx)(`button`,{className:`btn`,disabled:b||!v||!g||!f||!m.trim(),onClick:()=>void E(),children:i?`保存群引用`:`Save group reference`}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`btn`,disabled:b,onClick:()=>void E(!0),children:i?`解除引用`:`Unbind`}),(0,X.jsx)(`button`,{className:`btn primary`,disabled:!v||!w||b,onClick:()=>{t&&w&&C(c.current?.send({type:`canvas_run_all`,graphId:t.graphId,cwd:t.cwd})?i?`已请求启动,等待画布运行状态。`:`Run requested; waiting for canvas status.`:i?`画布连接已断开。`:`Canvas disconnected.`)},children:i?`启动绑定画布`:`Run bound canvas`})]}),S&&(0,X.jsx)(`p`,{role:`status`,children:S})]})}async function Oe(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,signal:t,headers:n?{"Content-Type":`application/json`}:void 0,body:n?JSON.stringify(n):void 0}),a=await i.json();if(!i.ok)throw Error(a.error??`HTTP ${i.status}`);return a}function ke({bots:e,preferredBotId:t,onSaved:n}){let r=D(a().locale),[i,o]=(0,J.useState)(t??e[0]?.id??``),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(0),y=(0,J.useRef)(null);(0,J.useEffect)(()=>{!i&&e.length&&o(t??e[0].id)},[i,e,t]);let b=e.find(e=>e.id===i),x=!!l&&!!b?.deviceId&&b.deviceId!==l;(0,J.useEffect)(()=>{let e=new AbortController;return y.current=e,m(!1),c(null),g(``),(async()=>{let t=await Oe(`chat-status`,e.signal);if(u(t.deviceId??``),!i||b?.deviceId&&t.deviceId!==b.deviceId)return;let n=await Oe(`local-bots/${encodeURIComponent(i)}`,e.signal);e.signal.aborted||c(n.bot)})().catch(t=>{e.signal.aborted||g(t.message)}),()=>e.abort()},[i,b?.deviceId,_]);async function S(){let e=y.current;if(s&&!x&&d.trim()&&e&&!e.signal.aborted){m(!0),g(``);try{let t=await Oe(`local-bots/${encodeURIComponent(s.id)}/preset`,e.signal,{revision:s.revision,preset:JSON.parse(d)});if(e.signal.aborted)return;c(t.bot),n(),g(`${r?`已保存新版本`:`Saved revision`} v${t.bot.revision}${t.synced?``:r?`;Hub同步待重试`:`; Hub sync pending`}`)}catch(t){e.signal.aborted||g(t.message)}finally{e.signal.aborted||m(!1)}}}return(0,X.jsxs)(`details`,{className:`group-ecosystem-panel`,children:[(0,X.jsx)(`summary`,{children:r?`Bot 配置与预设`:`Bot configuration and presets`}),(0,X.jsxs)(`label`,{children:[`Bot`,(0,X.jsxs)(`select`,{value:i,disabled:p,onChange:e=>o(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:r?`选择 Bot`:`Select Bot`}),e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsx)(`p`,{children:r?`仅编辑本机 Bot。保存创建新 revision;忙碌的 Bot 会拒绝修改,在途任务不热改。`:`Edit local Bots only. Saving creates a new revision. Busy Bots reject edits; in-flight tasks retain their configuration.`}),x&&(0,X.jsx)(`p`,{role:`status`,children:r?`此 Bot 在远程设备。请在该设备的本机界面读取和保存配置。`:`This Bot belongs to a remote device. Read and save its configuration in that device's local UI.`}),s&&!x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{children:[s.name,` · v`,s.revision,` · `,s.cwd]}),(0,X.jsxs)(`p`,{children:[r?`模型`:`Model`,`:`,` `,s.model?`${s.model.provider}/${s.model.modelId}`:r?`跟随设备默认`:`Device default`]}),(0,X.jsxs)(`p`,{children:[r?`已授权工具`:`Authorized tools`,`: `,s.tools.join(`, `)||(r?`无`:`None`)]}),(0,X.jsxs)(`label`,{children:[r?`可选预设 JSON(仅填写要修改的字段)`:`Optional preset JSON (include only fields to change)`,(0,X.jsx)(`textarea`,{rows:6,value:d,onChange:e=>f(e.target.value),placeholder:`{"systemPrompt":"…"}`})]}),(0,X.jsx)(`p`,{children:r?`允许字段:model、tools、skills、mcpServers、systemPrompt。省略字段保留当前值;工具、技能、MCP及模型须在本机目录中可用。`:`Allowed fields: model, tools, skills, mcpServers, systemPrompt. Omitted fields retain current values. Tools, skills, MCP and models must be available locally.`}),(0,X.jsx)(`button`,{className:`btn`,disabled:p,onClick:()=>v(e=>e+1),children:r?`重新读取配置`:`Reload configuration`}),(0,X.jsx)(`button`,{className:`btn primary`,disabled:p||!d.trim(),onClick:()=>void S(),children:r?`保存为新 revision(基于 v${s.revision})`:`Save new revision (based on v${s.revision})`})]}),h&&(0,X.jsx)(`p`,{role:`status`,children:h})]})}var Ae=[{id:`architecture`,titleZh:`架构设计`,titleEn:`Architecture`,aliases:[`架构设计`,`系统架构`,`architecture`,`system architecture`,`架构契约`,`技术方案`]},{id:`contracts`,titleZh:`接口契约`,titleEn:`Contracts`,aliases:[`接口契约`,`接口规范`,`contracts`,`api contracts`,`api规范`,`协议契约`,`数据契约`]},{id:`progress`,titleZh:`任务分工`,titleEn:`Task Progress`,aliases:[`任务分工`,`分工与进度`,`progress`,`tasks`,`task progress`,`流水线分工`,`任务流水线`]},{id:`blockers`,titleZh:`阻塞与决策`,titleEn:`Blockers & Decisions`,aliases:[`阻塞与决策`,`决策记录`,`blockers`,`decisions`,`风险与阻塞`,`关键技术决策`]}];function je(e){if(!e||!e.trim())return{preamble:``,sections:[]};let t=e.split(/\r?\n/),n=[],r=``,i=``,a=[],o=[],s=!1;for(let e of t){let t=e.match(/^##\s+(.+)$/);if(t){let o=t[1].trim();s?(n.push({id:Me(r),title:r,content:a.join(`
|
|
4
|
+
`).map(e=>e.trim()).filter(Boolean),o=JSON.stringify([e,v,b,t,w]);M.current?.fingerprint!==o&&(M.current={fingerprint:o,key:crypto.randomUUID()});let c=await xe(`rooms/${encodeURIComponent(e)}/transfers/start`,a.signal,{idempotencyKey:M.current.key,sourceBotId:v,targetBotId:b,paths:t,recursive:w});if(n!==k.current||r!==A.current)return;p(i?`传输任务已成功启动 (ID: ${c.transferId?.slice(0,8)??``}),正在后台分块传输中。`:`Transfer started (ID: ${c.transferId?.slice(0,8)??``}), streaming chunks in background.`),_(!1),C(``),M.current=null;let l=await xe(`rooms/${encodeURIComponent(e)}/transfers`,a.signal);n===k.current&&r===A.current&&Array.isArray(l?.transfers)&&s(l.transfers)}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(a),n===k.current&&r===A.current&&O(!1)}},R=async t=>{let n=t.preview||(t.files?{id:t.transferId,revision:t.revision||``,files:t.files}:void 0);if(!n||u)return;let r=k.current,a=e,o=N();d(!0),h(``),p(i?`正在导入文件变更...`:`Applying file changes...`);try{let l=Array.from(c[t.transferId]||[]),u=await xe(`rooms/${encodeURIComponent(e)}/transfers/${encodeURIComponent(t.transferId)}/apply`,o.signal,{revision:n.revision,overwritePaths:l});if(r!==k.current||a!==A.current)return;p(i?`导入成功:已应用 ${u.applied?.length??0} 个文件,未变 ${u.unchanged?.length??0} 个`:`Apply successful: applied ${u.applied?.length??0}, unchanged ${u.unchanged?.length??0}`),s(e=>e.map(e=>e.transferId===t.transferId?{...e,status:`applied`}:e))}catch(e){r===k.current&&a===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(o),r===k.current&&a===A.current&&d(!1)}},z=async t=>{let n=k.current,r=e,a=N();try{if(await xe(`rooms/${encodeURIComponent(e)}/transfers/${encodeURIComponent(t.transferId)}/abort`,a.signal,{}),n!==k.current||r!==A.current)return;s(e=>e.map(e=>e.transferId===t.transferId?{...e,status:`cancelled`}:e)),p(i?`传输已取消,暂存文件与配额已物理释放`:`Transfer aborted; staged quota freed`)}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(a)}},B=async t=>{let n=k.current,r=e,i=N();try{let e=await xe(`rooms/${encodeURIComponent(r)}/transfers/${encodeURIComponent(t.transferId)}/resume`,i.signal,{manifestHash:t.manifestHash,sourceBotRevision:t.sourceBotRevision,targetBotRevision:t.targetBotRevision});n===k.current&&r===A.current&&s(n=>n.map(n=>n.transferId===t.transferId?e:n))}catch(e){n===k.current&&r===A.current&&h(e instanceof Error?e.message:String(e))}finally{j.current.delete(i)}},V=o.filter(e=>[`queued`,`staging`,`cancelling`].includes(e.status)).length,H=o.filter(e=>e.status===`staged`||e.status===`ready`).length;return(0,X.jsxs)(`details`,{className:`dft-panel`,open:o.length>0,children:[(0,X.jsxs)(`summary`,{className:`dft-summary`,children:[(0,X.jsx)(`span`,{className:`dft-title-icon`,children:`📦`}),(0,X.jsx)(`span`,{children:i?`跨机大文件传输与断点续传`:`Cross-Device Chunked File Transfers`}),o.length>0&&(0,X.jsx)(`span`,{className:`dft-badge`,children:V>0?i?`${V} 个传输中`:`${V} streaming`:H>0?i?`${H} 个待导入`:`${H} staged`:`${o.length}`})]}),(0,X.jsxs)(`div`,{className:`dft-content`,children:[m&&(0,X.jsx)(`div`,{className:`dft-alert dft-alert-error`,role:`alert`,children:m}),f&&(0,X.jsx)(`div`,{className:`dft-alert dft-alert-info`,children:f}),(0,X.jsx)(`div`,{className:`dft-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn dft-btn-toggle`,onClick:()=>_(e=>!e),disabled:n||t.length<2,children:g?i?`收起传输表单`:`Close Transfer Form`:i?`+ 发起新文件/目录传输`:`+ New File/Directory Transfer`})}),g&&(0,X.jsxs)(`form`,{className:`dft-start-form`,onSubmit:L,children:[(0,X.jsxs)(`div`,{className:`dft-form-row`,children:[(0,X.jsxs)(`label`,{className:`dft-form-label`,children:[(0,X.jsx)(`span`,{children:i?`源机器人 (发送端)`:`Source Bot (Sender)`}),(0,X.jsx)(`select`,{className:`dft-select`,value:v,onChange:e=>y(e.target.value),disabled:n||E,children:t.map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name||e.id,` (`,e.id.slice(0,8),`)`]},e.id))})]}),(0,X.jsxs)(`label`,{className:`dft-form-label`,children:[(0,X.jsx)(`span`,{children:i?`目标机器人 (接收端)`:`Target Bot (Receiver)`}),(0,X.jsx)(`select`,{className:`dft-select`,value:b,onChange:e=>x(e.target.value),disabled:n||E,children:t.filter(e=>e.id!==v).map(e=>(0,X.jsxs)(`option`,{value:e.id,children:[e.name||e.id,` (`,e.id.slice(0,8),`)`]},e.id))})]})]}),(0,X.jsx)(`div`,{className:`dft-form-row`,children:(0,X.jsxs)(`label`,{className:`dft-form-label full-width`,children:[(0,X.jsx)(`span`,{children:i?`相对路径(文件或目录,每行一个)`:`Project-relative paths (one per line)`}),(0,X.jsx)(`textarea`,{className:`dft-textarea`,rows:2,placeholder:i?`如: src/ 或 large-asset.bin`:`e.g. src/ or data/model.weights`,value:S,onChange:e=>C(e.target.value),disabled:n||E})]})}),(0,X.jsxs)(`div`,{className:`dft-form-footer`,children:[(0,X.jsxs)(`label`,{className:`dft-checkbox-label`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:w,onChange:e=>T(e.target.checked),disabled:n||E}),(0,X.jsx)(`span`,{children:i?`递归包含子目录 (recursive)`:`Recursive directory traversal`})]}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary dft-btn-submit`,disabled:n||E||!S.trim()||v===b,children:E?i?`启动中...`:`Starting...`:i?`开始分块传输`:`Start Transfer`})]})]}),o.length===0?(0,X.jsxs)(`div`,{className:`dft-empty`,children:[(0,X.jsx)(`p`,{children:i?`当前群暂无文件传输记录。`:`No active file transfers in this room.`}),(0,X.jsx)(`span`,{className:`dft-hint`,children:i?`支持突破 8MiB 限制的大文件及 >128 文件的目录分块传输。发起后将在此实时展示进度与断点续传状态。`:`Supports >8MiB files and 128+ file directories. Live progress, chunk checksums and resume controls appear here.`})]}):(0,X.jsx)(`div`,{className:`dft-transfers-list`,children:o.map(e=>{let t=Math.min(100,Math.max(0,e.percent??0)),r=e.preview?.files||e.files||[],a=c[e.transferId]||new Set;return(0,X.jsxs)(`div`,{className:`dft-card dft-card-${e.status}`,children:[(0,X.jsxs)(`div`,{className:`dft-card-header`,children:[(0,X.jsxs)(`div`,{className:`dft-route`,children:[(0,X.jsx)(`span`,{className:`dft-bot-name`,children:F(e.sourceBotId)}),(0,X.jsx)(`span`,{className:`dft-arrow`,children:`➔`}),(0,X.jsx)(`span`,{className:`dft-bot-name`,children:F(e.targetBotId)}),(0,X.jsx)(`span`,{className:`dft-id-badge`,title:e.transferId,children:e.transferId.slice(0,8)})]}),(0,X.jsxs)(`span`,{className:`dft-status-tag dft-tag-${e.status}`,children:[e.status===`staging`&&(i?`分块传输中`:`Streaming`),(e.status===`staged`||e.status===`ready`)&&(i?`待确认导入`:`Ready`),e.status===`queued`&&(i?`排队中`:`Queued`),e.status===`interrupted`&&(i?`已中断`:`Interrupted`),e.status===`cancelling`&&(i?`取消中`:`Cancelling`),e.status===`applying`&&(i?`导入中`:`Applying`),e.status===`applied`&&(i?`已导入`:`Applied`),e.status===`cancelled`&&(i?`已取消`:`Cancelled`),e.status===`failed`&&(i?`失败`:`Failed`)]})]}),(0,X.jsxs)(`div`,{className:`dft-metrics`,children:[(0,X.jsxs)(`span`,{children:[i?`文件: `:`Files: `,(0,X.jsx)(`strong`,{children:e.totalFiles==null?`-`:e.totalFiles})]}),(0,X.jsxs)(`span`,{children:[i?`大小: `:`Size: `,(0,X.jsx)(`strong`,{children:e.totalBytes==null?`-`:be(e.totalBytes)})]}),(0,X.jsxs)(`span`,{children:[i?`分块: `:`Chunks: `,(0,X.jsx)(`strong`,{children:e.totalChunks==null?`-`:`${e.receivedChunks?.length??0} / ${e.totalChunks}`})]})]}),(0,X.jsx)(`div`,{className:`dft-progress-bar-wrap`,children:(0,X.jsx)(`div`,{className:`dft-progress-bar`,style:{width:`${t}%`}})}),(0,X.jsxs)(`div`,{className:`dft-progress-label`,children:[(0,X.jsxs)(`span`,{children:[t,`%`]}),(0,X.jsx)(`span`,{className:`dft-hash-status`,children:e.status===`staged`||e.status===`ready`||e.status===`applied`?i?`✓ SHA256 完整校验通过`:`✓ SHA256 Verified`:e.status===`cancelled`?i?`传输已取消`:`Transfer cancelled`:e.status===`failed`?i?`传输失败`:`Transfer failed`:e.status===`interrupted`?i?`传输已中断`:`Transfer interrupted`:i?`32KiB 有界分块传输与断点校验中`:`32KiB Bounded Chunk Streaming`})]}),e.error&&(0,X.jsx)(`div`,{className:`dft-item-error`,title:e.error,children:e.error}),r.length>0&&(0,X.jsxs)(`div`,{className:`dft-preview-section`,children:[(0,X.jsx)(`div`,{className:`dft-preview-title`,children:i?`变更差异预览:`:`File Changes Preview:`}),(0,X.jsx)(`div`,{className:`dft-files-table`,children:r.map(t=>(0,X.jsxs)(`div`,{className:`dft-file-row dft-file-${t.status}`,children:[(0,X.jsxs)(`span`,{className:`dft-file-status-icon`,children:[t.status===`create`&&`➕`,t.status===`identical`&&`✓`,t.status===`conflict`&&`⚠️`]}),(0,X.jsx)(`span`,{className:`dft-file-path`,title:t.path,children:t.path}),(0,X.jsx)(`span`,{className:`dft-file-size`,children:be(t.size)}),t.status===`conflict`&&(0,X.jsxs)(`label`,{className:`dft-overwrite-toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a.has(t.path),onChange:()=>I(e.transferId,t.path),disabled:n||e.status!==`staged`&&e.status!==`ready`}),(0,X.jsx)(`span`,{children:i?`显式覆盖`:`Overwrite`})]})]},t.path))})]}),(0,X.jsxs)(`div`,{className:`dft-card-actions`,children:[e.status===`interrupted`&&e.manifestHash&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:n,onClick:()=>B(e),children:i?`按原版本续传`:`Resume saved version`}),!e.applyStarted&&[`queued`,`staging`,`ready`,`interrupted`,`failed`].includes(e.status)&&(0,X.jsx)(`button`,{type:`button`,className:`btn dft-btn-abort`,onClick:()=>z(e),disabled:n,children:i?`取消传输`:`Abort Transfer`}),(e.status===`staged`||e.status===`ready`)&&(0,X.jsx)(`button`,{type:`button`,className:`btn primary dft-btn-apply`,onClick:()=>R(e),disabled:n||u,children:u?i?`导入中...`:`Applying...`:i?`确认导入变更 (Apply)`:`Confirm Apply`})]})]},e.transferId)})})]})]})}async function Ce(e,t){let n=await fetch(r(o(`/api/device-center/${e}`)),{method:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(15e3)])}),i=await n.json().catch(()=>({}));if(!n.ok)throw Error(i.error||`HTTP ${n.status}`);return i}function we({roomId:e,taskId:t,onClose:n}){let{locale:r}=a(),i=D(r),[o,s]=(0,J.useState)(null),[c,l]=(0,J.useState)([]),[u,d]=(0,J.useState)(null),[f,p]=(0,J.useState)(!0),[m,h]=(0,J.useState)(!1),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(``),[b,x]=(0,J.useState)(`journal`),[S,C]=(0,J.useState)(null),[w,T]=(0,J.useState)(``),[E,O]=(0,J.useState)(!1),[k,A]=(0,J.useState)(void 0),[j,M]=(0,J.useState)(!1),[N,P]=(0,J.useState)(!1),F=(0,J.useRef)(null),I=(0,J.useRef)(null),L=(0,J.useRef)(null),R=(0,J.useRef)(n);R.current=n,(0,J.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),R.current())};return window.addEventListener(`keydown`,e),L.current?.focus(),()=>{window.removeEventListener(`keydown`,e)}},[]),(0,J.useEffect)(()=>{F.current?.abort();let n=new AbortController;F.current=n,s(null),l([]),d(null),T(``),C(null),O(!1),A(void 0),P(!1),_(``),y(``),p(!0);async function r(){let[r,a]=await Promise.allSettled([Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`,n.signal),Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/journal?limit=25&direction=forward`,n.signal)]);if(!n.signal.aborted){if(r.status===`fulfilled`){let e=r.value;s(e),e.reportMeta&&C(e.reportMeta)}else _(r.reason?.message||`Failed to load task details`);a.status===`fulfilled`?(l(a.value.items),d(a.value)):y(a.reason?.message||(i?`加载事件流失败`:`Failed to load journal`)),p(!1)}}return r(),()=>{n.abort(),I.current!==null&&(clearTimeout(I.current),I.current=null)}},[e,t]);async function z(){if(!u?.nextCursor||m)return;let n=F.current??new AbortController;h(!0);try{let r=await Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/journal?limit=25&direction=forward&cursor=${encodeURIComponent(u.nextCursor)}`,n.signal);if(n.signal.aborted)return;l(e=>[...e,...r.items]),d(r)}catch(e){n.signal.aborted||y(e?.message||(i?`分页加载日志失败`:`Failed to load more journal events`))}finally{n.signal.aborted||h(!1)}}async function B(n){let r=F.current??new AbortController;M(!0);try{let i=n===void 0?`?offset=0&limit=262144`:`?offset=${n}&limit=262144`,a=await Ce(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/report${i}`,r.signal);if(r.signal.aborted)return;C(a.meta);let o=a.text??``;T(e=>n===void 0||n===0?o:e+o),O(!!a.hasMore),A(a.nextOffset??void 0)}catch(e){r.signal.aborted||_(i?`加载报告分片失败: ${e.message}`:`Failed to load report slice: ${e.message}`)}finally{r.signal.aborted||M(!1)}}function V(){w&&navigator.clipboard.writeText(w).then(()=>{P(!0),I.current!==null&&clearTimeout(I.current),I.current=window.setTimeout(()=>{P(!1),I.current=null},2e3)}).catch(()=>{_(i?`复制报告失败,请手动选择复制`:`Failed to copy report to clipboard`)})}let H=c.filter(e=>e.toolName||e.type.startsWith(`tool_`)||e.parametersPreview&&Object.keys(e.parametersPreview).length>0),U=o?.task;function ee(e){let t=e||`queued`,n={queued:{zh:`排队中`,en:`Queued`,cls:`gtd-badge-queued`},running:{zh:`运行中`,en:`Running`,cls:`gtd-badge-running`},completed:{zh:`已完成`,en:`Completed`,cls:`gtd-badge-completed`},failed:{zh:`失败`,en:`Failed`,cls:`gtd-badge-failed`},interrupted:{zh:`已中断`,en:`Interrupted`,cls:`gtd-badge-interrupted`}}[t]||{zh:t,en:t,cls:`gtd-badge-queued`};return(0,X.jsx)(`span`,{className:`gtd-badge ${n.cls}`,children:i?n.zh:n.en})}return(0,X.jsx)(`div`,{className:`gtd-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":i?`任务详情`:`Task Details`,children:(0,X.jsxs)(`div`,{className:`gtd-panel`,ref:L,tabIndex:-1,children:[(0,X.jsxs)(`div`,{className:`gtd-header`,children:[(0,X.jsxs)(`div`,{className:`gtd-header-title`,children:[(0,X.jsx)(`h3`,{children:i?`群任务详情与操作审计`:`Group Task Details & Audit Log`}),U&&(0,X.jsxs)(`span`,{className:`gtd-task-id`,children:[`#`,U.id.slice(0,8)]}),U&&ee(U.status)]}),(0,X.jsx)(`button`,{type:`button`,className:`btn gtd-close-btn gtd-close`,onClick:n,children:`✕`})]}),g&&(0,X.jsx)(`div`,{className:`gtd-error-banner`,role:`alert`,children:g}),f?(0,X.jsx)(`div`,{className:`gtd-loading`,children:i?`加载任务详情中...`:`Loading task details...`}):(0,X.jsxs)(`div`,{className:`gtd-body`,children:[U&&(0,X.jsxs)(`div`,{className:`gtd-overview-card`,children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`目标内容:`:`Objective:`}),(0,X.jsx)(`span`,{className:`gtd-value gtd-task-text`,children:U.text})]}),(0,X.jsxs)(`div`,{className:`gtd-meta-row`,children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`执行 Bot:`:`Bot:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:U.botName||U.botId})]}),U.deviceName&&(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`运行设备:`:`Device:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:U.deviceName})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`创建时间:`:`Created:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:new Date(U.createdAt).toLocaleTimeString()})]})]}),U.queuedReason&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-info`,children:[(0,X.jsx)(`strong`,{children:i?`排队原因:`:`Queued Reason:`}),` `,U.queuedReason]}),U.interruptedReason&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[(0,X.jsx)(`strong`,{children:i?`中断原因:`:`Interruption Reason:`}),` `,U.interruptedReason]})]}),o&&o.interactions.length>0&&(0,X.jsxs)(`div`,{className:`gtd-section`,children:[(0,X.jsx)(`h4`,{children:i?`关联人工审批与问卷`:`Associated Human Interactions`}),(0,X.jsx)(`div`,{className:`gtd-interaction-list`,children:o.interactions.map(e=>(0,X.jsxs)(`div`,{className:`gtd-interaction-item`,children:[(0,X.jsxs)(`div`,{className:`gtd-interaction-header`,children:[(0,X.jsx)(`span`,{className:`gtd-interaction-kind`,children:e.kind}),(0,X.jsx)(`span`,{className:e.resolved?`gtd-badge-completed`:`gtd-badge-queued`,children:e.resolved?i?`已裁决`:`Resolved`:i?`待处理`:`Pending`})]}),e.question&&(0,X.jsx)(`div`,{className:`gtd-interaction-q`,children:e.question}),e.decision&&(0,X.jsxs)(`div`,{className:`gtd-interaction-ans`,children:[i?`裁决结论: `:`Decision: `,` `,e.decision]})]},e.id))})]}),o&&o.deliveries.length>0&&(0,X.jsxs)(`div`,{className:`gtd-section`,children:[(0,X.jsx)(`h4`,{children:i?`关联代码交付`:`Associated Code Deliveries`}),(0,X.jsx)(`div`,{className:`gtd-delivery-list`,children:o.deliveries.map(e=>(0,X.jsxs)(`div`,{className:`gtd-delivery-item`,children:[(0,X.jsxs)(`div`,{className:`gtd-delivery-header`,children:[e.commit&&(0,X.jsx)(`span`,{className:`gtd-commit-sha`,children:e.commit.slice(0,8)}),e.branch&&(0,X.jsx)(`span`,{className:`gtd-branch-chip`,children:e.branch}),(0,X.jsx)(`span`,{className:e.reportedCheckCount===0?`gtd-badge-queued`:e.passed?`gtd-badge-completed`:`gtd-badge-failed`,children:e.reportedCheckCount===0?i?`未自报检查`:`No reported checks`:e.passed?i?`自报检查通过`:`Reported checks passed`:i?`自报检查未通过`:`Reported checks not passed`})]}),(0,X.jsx)(`div`,{className:`gtd-delivery-summary`,children:e.summary}),e.artifactRef&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`交付版本 ID:`:`Delivery version ID:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.id})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`产物:`:`Artifact:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactId})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`源码任务:`:`Source task:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactTaskId})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`内容摘要:`:`Content digest:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.artifactDigest})]}),(0,X.jsxs)(`div`,{className:`gtd-field`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`文件树版本:`:`File tree version:`}),(0,X.jsx)(`span`,{className:`gtd-value`,children:e.artifactRef.outputTree})]})]})]},e.id))})]}),(0,X.jsxs)(`div`,{className:`gtd-tabs`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`gtd-tab ${b===`journal`?`active`:``}`,onClick:()=>x(`journal`),children:[i?`事件与审计流`:`Journal Events`,` (`,c.length,`)`]}),(0,X.jsxs)(`button`,{type:`button`,className:`gtd-tab ${b===`tools`?`active`:``}`,onClick:()=>x(`tools`),children:[i?`工具调用卡片`:`Tool Lifecycles`,` (`,H.length,`)`]}),(0,X.jsx)(`button`,{type:`button`,className:`gtd-tab ${b===`report`?`active`:``}`,onClick:()=>{x(`report`),w||(M(!0),B())},children:i?`任务完整报告`:`Full Report Log`})]}),b===`journal`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[u?.truncated&&(0,X.jsxs)(`div`,{className:`gtd-truncation-notice`,children:[`⚠️`,` `,i?`由于日志保留配额,最早的 ${u.droppedCount} 条事件已自动淘汰。系统明确标记并不伪装历史完整。`:`The earliest ${u.droppedCount} events were pruned due to journal retention quota. History is not disguised as complete.`]}),u?.cursorExpired&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`游标所在的分段已淘汰,显示当前保留的最旧事件。`:`The requested cursor was pruned from disk; showing oldest retained segments.`}),u?.corrupted&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`部分分段可能存在损坏行,已保留损坏证据。`:`Corrupted lines detected and flagged.`}),v&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,role:`alert`,children:v}),u?.journalUnavailable&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,children:i?`事件日志写入失败或被降级,审计流可能不完整。`:`Journal persistence failed or degraded; the audit trail may be incomplete.`}),c.length===0?(0,X.jsx)(`div`,{className:`gtd-empty`,children:i?`暂无事件记录`:`No journal events recorded.`}):(0,X.jsx)(`div`,{className:`gtd-journal-list`,children:c.map(e=>(0,X.jsxs)(`div`,{className:`gtd-journal-entry`,children:[(0,X.jsxs)(`div`,{className:`gtd-entry-meta`,children:[(0,X.jsxs)(`span`,{className:`gtd-entry-seq`,children:[`#`,e.sequence]}),(0,X.jsx)(`span`,{className:`gtd-entry-type`,children:e.type}),(0,X.jsx)(`span`,{className:`gtd-entry-time`,children:new Date(e.timestamp).toLocaleTimeString()})]}),e.summary&&(0,X.jsx)(`div`,{className:`gtd-entry-summary`,children:e.summary}),e.output&&(0,X.jsx)(`pre`,{className:`gtd-entry-output`,children:e.output}),e.reason&&(0,X.jsx)(`div`,{className:`gtd-entry-reason`,children:e.reason})]},e.id))}),u?.hasMore&&(0,X.jsx)(`div`,{className:`gtd-load-more-row`,children:(0,X.jsx)(`button`,{type:`button`,className:`btn gtd-load-more-btn`,disabled:m,onClick:z,children:m?i?`加载中...`:`Loading...`:i?`加载更多历史事件`:`Load more journal events`})})]}),b===`tools`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[v&&(0,X.jsx)(`div`,{className:`gtd-callout gtd-callout-warning`,role:`alert`,children:v}),H.length===0?(0,X.jsx)(`div`,{className:`gtd-empty`,children:i?`本任务暂无工具调用记录`:`No tool invocations recorded.`}):(0,X.jsx)(`div`,{className:`gtd-tool-cards`,children:H.map(e=>(0,X.jsxs)(`div`,{className:`gtd-tool-card`,children:[(0,X.jsxs)(`div`,{className:`gtd-tool-card-head`,children:[(0,X.jsx)(`strong`,{children:e.toolName||`tool`}),(0,X.jsx)(`span`,{className:`gtd-tool-phase`,children:e.type})]}),e.parametersPreview&&(0,X.jsxs)(`div`,{className:`gtd-tool-params`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`安全参数摘要:`:`Parameters:`}),(0,X.jsx)(`pre`,{children:JSON.stringify(e.parametersPreview,null,2)})]}),e.output&&(0,X.jsxs)(`div`,{className:`gtd-tool-output`,children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`增量安全输出:`:`Output Snippet:`}),(0,X.jsx)(`pre`,{children:e.output})]})]},e.id))})]}),b===`report`&&(0,X.jsxs)(`div`,{className:`gtd-tab-content`,children:[S&&(0,X.jsxs)(`div`,{className:`gtd-report-meta-box`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`存储位置:`:`Storage:`}),` `,(0,X.jsxs)(`code`,{children:[S.storageLocation.role,`::`,S.storageLocation.reportRef]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`报告总大小:`:`Total Size:`}),` `,(0,X.jsxs)(`span`,{children:[S.totalBytes,` bytes`]})]}),S.sha256&&(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`完整性 SHA256:`:`SHA256:`}),` `,(0,X.jsxs)(`code`,{children:[S.sha256.slice(0,16),`...`]})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{className:`gtd-label`,children:i?`当前已加载:`:`Loaded Size:`}),` `,(0,X.jsxs)(`span`,{children:[new TextEncoder().encode(w).length,` bytes`]})]}),S.quotaExceeded&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[`⚠️`,` `,i?`报告超过配额硬限制 (${S.quotaLimit} bytes),系统明确拒绝接收超额部分,绝不伪装完整。`:`Report exceeded quota limit (${S.quotaLimit} bytes) and was rejected without partial truncation disguise.`]}),S.uploadPending&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-info`,children:[`⏳ `,i?`完整报告正在由执行设备分块同步中...`:`Full report chunk sync in progress...`]}),S.missing&&!S.uploadPending&&(0,X.jsxs)(`div`,{className:`gtd-callout gtd-callout-warning`,children:[`⚠️ `,i?`执行设备尚未上传完整报告原文。`:`Full report has not yet been uploaded by device.`]})]}),(0,X.jsxs)(`div`,{className:`gtd-report-actions`,children:[E&&(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:j,onClick:()=>B(k),children:j?i?`加载中...`:`Loading...`:i?`加载更多报告内容`:`Load more report`}),(0,X.jsx)(`button`,{type:`button`,className:`btn`,disabled:j||!w,onClick:V,children:N?i?`已复制`:`Copied!`:i?`复制报告全文`:`Copy Report`})]}),j&&!w?(0,X.jsx)(`div`,{className:`gtd-loading`,children:i?`正在读取报告文件...`:`Loading report file...`}):(0,X.jsx)(`pre`,{className:`gtd-report-viewer gtd-report-text`,children:w})]})]})]})})}var Te={zh:{planTitle:`群任务计划`,planDraft:`计划草稿编制中`,planReady:`计划已就绪(需确认后开始)`,planApproved:`计划已批准实施`,startPlan:`开始实施`,startingPlan:`正在启动…`,canvasTitle:`关联画布工作流`,canvasManualNote:`画布已就绪。引用不会自动运行,点击按钮显式启动。`,launchCanvas:`启动画布`,launchingCanvas:`正在启动画布…`,botPresetTitle:`Bot 运行快照`,lockedSnapshot:`在途任务快照已锁定(v{rev})`,toolsCount:`已授权 {count} 个工具`,isolatedNote:`独立隔离运行,未共享主会话私有配置`,applyPreset:`应用最新快照`,applyingPreset:`应用中…`,lockedCannotApply:`在途任务禁止热改预设`},en:{planTitle:`Group Task Plan`,planDraft:`Drafting plan`,planReady:`Plan Ready (Requires confirmation to start)`,planApproved:`Plan approved & executing`,startPlan:`Start Execution`,startingPlan:`Starting…`,canvasTitle:`Linked Canvas Workflow`,canvasManualNote:`Canvas attached. Workflow will not run automatically. Click to launch explicitly.`,launchCanvas:`Launch Canvas`,launchingCanvas:`Launching canvas…`,botPresetTitle:`Bot Preset Snapshot`,lockedSnapshot:`Active task snapshot locked (v{rev})`,toolsCount:`{count} authorized tools`,isolatedNote:`Isolated run, main session private config is not leaked`,applyPreset:`Apply Latest Snapshot`,applyingPreset:`Applying…`,lockedCannotApply:`Active tasks cannot hot-reload presets`}};function Ee({roomId:e,activeTaskId:t,taskSnapshotRevision:n,planState:r,canvasRef:o,botSnapshot:s,onStartPlanExecution:c,onLaunchCanvas:l,onApplyPresetSnapshot:u,uiSlotEntries:d,onUiAction:f,className:m}){let{locale:h}=a(),g=Te[D(h)?`zh`:`en`],v=(0,J.useRef)(e);(0,J.useEffect)(()=>{v.current=e,j(null),x(!1),C(!1),T(!1)},[e]);let[y,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)(!1),[k,j]=(0,J.useState)(null);return k||r||o||s||d&&d.length>0?(0,X.jsxs)(`div`,{className:`group-workspace-actions ${m??``}`.trim(),children:[k&&(0,X.jsxs)(`div`,{className:`group-workspace-error-banner`,role:`alert`,children:[(0,X.jsx)(O,{className:`error-icon`}),(0,X.jsx)(`span`,{children:k})]}),r&&(0,X.jsxs)(`div`,{className:`group-workspace-card plan-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(E,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.planTitle}),(0,X.jsxs)(`span`,{className:`plan-badge status-${r.state}`,children:[r.state===`draft`&&g.planDraft,r.state===`ready`&&g.planReady,r.state===`approved`&&g.planApproved]})]}),r.steps&&r.steps.length>0&&(0,X.jsx)(`ul`,{className:`plan-steps-list`,children:r.steps.map(e=>(0,X.jsxs)(`li`,{className:`step-item status-${e.status??`pending`}`,children:[(0,X.jsx)(P,{className:`step-icon`}),(0,X.jsx)(`span`,{className:`step-title`,children:e.title})]},e.id))}),r.state===`ready`&&c&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn primary start-plan-btn`,onClick:async()=>{if(!t||!r||y||!c)return;let n=ie(r);if(!n.ok){j(n.reason??`Plan is not ready for approval`);return}j(null),x(!0);try{await c(t)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&x(!1)}},disabled:y,children:[(0,X.jsx)(i,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:y?g.startingPlan:g.startPlan})]})})]}),o&&(0,X.jsxs)(`div`,{className:`group-workspace-card canvas-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(b,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.canvasTitle}),(0,X.jsx)(`span`,{className:`canvas-badge`,children:o.title||o.graphId})]}),(0,X.jsx)(`p`,{className:`card-note`,children:g.canvasManualNote}),l&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn launch-canvas-btn`,onClick:async()=>{if(o&&!S&&l&&!ae(o)){j(null),C(!0);try{await l(o.graphId)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&C(!1)}}},disabled:S,children:[(0,X.jsx)(i,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:S?g.launchingCanvas:g.launchCanvas})]})})]}),s&&(0,X.jsxs)(`div`,{className:`group-workspace-card bot-preset-card`,children:[(0,X.jsxs)(`div`,{className:`card-header`,children:[(0,X.jsx)(A,{className:`card-icon`}),(0,X.jsx)(`span`,{className:`card-title`,children:g.botPresetTitle}),(0,X.jsx)(`span`,{className:`bot-badge`,children:s.name})]}),(0,X.jsxs)(`div`,{className:`bot-snapshot-meta`,children:[(0,X.jsxs)(`span`,{className:`snapshot-rev`,children:[(0,X.jsx)(p,{className:`rev-icon`}),g.lockedSnapshot.replace(`{rev}`,String(s.revision))]}),(0,X.jsx)(`span`,{className:`snapshot-tools`,children:g.toolsCount.replace(`{count}`,String(s.toolWhitelist.length))})]}),(0,X.jsx)(`p`,{className:`card-note-faint`,children:g.isolatedNote}),u&&(0,X.jsx)(`div`,{className:`card-actions`,children:(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary apply-preset-btn`,onClick:async()=>{if(s&&!w&&u){if(!q(n,s.revision)){j(g.lockedCannotApply);return}j(null),T(!0);try{let e=re(s,s.botId,s.revision+1);await u(s.botId,e)}catch(t){v.current===e&&j(t instanceof Error?t.message:String(t))}finally{v.current===e&&T(!1)}}},disabled:w||!q(n,s.revision),title:q(n,s.revision)?void 0:g.lockedCannotApply,children:[(0,X.jsx)(_,{className:`btn-icon`}),(0,X.jsx)(`span`,{children:w?g.applyingPreset:g.applyPreset})]})})]}),d&&d.length>0&&(0,X.jsxs)(`div`,{className:`group-workspace-card group-slots-card`,children:[(0,X.jsx)(`div`,{className:`card-header`,children:(0,X.jsx)(`span`,{className:`card-title`,children:D(h)?`扩展操作`:`Extensions`})}),(0,X.jsx)(`div`,{className:`card-actions group-slots-actions`,children:d.filter(e=>!e.hidden).map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn secondary group-slot-btn`,onClick:()=>f?.(e),title:e.label,children:e.label},e.id))})]})]}):null}function De({roomId:e,binding:t,onSaved:n}){let i=D(a().locale),s=T(`cwd`),c=(0,J.useRef)(null),l=(0,J.useRef)(null),[u,d]=(0,J.useState)([]),[f,p]=(0,J.useState)(t?.graphId??``),[m,h]=(0,J.useState)(t?.cwd??s),[g,_]=(0,J.useState)(``),[v,y]=(0,J.useState)(!1),[b,x]=(0,J.useState)(!1),[S,C]=(0,J.useState)(``);(0,J.useEffect)(()=>{let e=new AbortController;l.current=e,x(!1),fetch(r(o(`/api/device-center/chat-status`)),{signal:e.signal}).then(async e=>{let t=await e.json();if(!e.ok||!t.deviceId)throw Error(t.error??`Local device identity unavailable`);_(t.deviceId)}).catch(t=>{e.signal.aborted||C(String(t.message))});let n=new oe({loadGraphOnConnect:!1});c.current=n;let i=n.subscribe(e=>{e.type===`canvas_list_result`&&d(e.graphs),e.type===`canvas_error`&&e.graphId===t?.graphId&&C(e.message),e.type===`canvas_node_event`&&e.graphId===t?.graphId&&C(`${e.nodeId}: ${e.event}`)}),a=n.subscribeConnection(y);return n.connect(),()=>{e.abort(),i(),a(),n.dispose(),c.current=null}},[t?.graphId,e]),(0,J.useEffect)(()=>{p(t?.graphId??``),h(t?.cwd??s)},[t?.graphId,t?.cwd,s]);let w=!!g&&(!t||t.deviceId===g);async function E(t=!1){let a=l.current;if(a&&!a.signal.aborted){x(!0),C(``);try{let s=u.find(e=>e.id===f);if(!t&&(!s||!m.trim()||!g))throw Error(`Select a local graph and workspace`);let c=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/canvas`)),{method:`POST`,signal:a.signal,headers:{"Content-Type":`application/json`},body:JSON.stringify({binding:t?null:{deviceId:g,graphId:f,cwd:m.trim(),title:s.name}})}),l=await c.json();if(!c.ok)throw Error(l.error??`Canvas binding failed`);if(a.signal.aborted)return;n(),C(i?`群画布引用已保存;点击启动才会执行。`:`Group canvas reference saved. Run explicitly to execute.`)}catch(e){a.signal.aborted||C(e.message)}finally{a.signal.aborted||x(!1)}}}return(0,X.jsxs)(`details`,{className:`group-ecosystem-panel`,children:[(0,X.jsxs)(`summary`,{children:[i?`群画布`:`Group canvas`,t?` · ${t.title}`:``]}),(0,X.jsx)(`p`,{children:i?`引用保存在群组中。运行发生在绑定设备,使用下方工作目录;保存引用不会运行。`:`References are saved with the group. Runs use the bound device and workspace. Saving does not run the graph.`}),t&&(0,X.jsxs)(`p`,{children:[t.deviceId,` · `,t.graphId,` · `,t.cwd]}),!w&&t&&(0,X.jsx)(`p`,{role:`status`,children:i?`此画布属于另一台设备,请在该设备打开群组后运行。可选择本机画布重新绑定。`:`This canvas belongs to another device. Open the group there to run it, or bind a local canvas.`}),(0,X.jsxs)(`label`,{children:[i?`本机工程`:`Local graph`,(0,X.jsxs)(`select`,{value:f,onChange:e=>p(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:i?`选择画布`:`Select canvas`}),u.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsxs)(`label`,{children:[i?`本机工作目录`:`Local workspace`,(0,X.jsx)(`input`,{value:m,onChange:e=>h(e.target.value)})]}),(0,X.jsx)(`button`,{className:`btn`,disabled:b||!v||!g||!f||!m.trim(),onClick:()=>void E(),children:i?`保存群引用`:`Save group reference`}),t&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{className:`btn`,disabled:b,onClick:()=>void E(!0),children:i?`解除引用`:`Unbind`}),(0,X.jsx)(`button`,{className:`btn primary`,disabled:!v||!w||b,onClick:()=>{t&&w&&C(c.current?.send({type:`canvas_run_all`,graphId:t.graphId,cwd:t.cwd})?i?`已请求启动,等待画布运行状态。`:`Run requested; waiting for canvas status.`:i?`画布连接已断开。`:`Canvas disconnected.`)},children:i?`启动绑定画布`:`Run bound canvas`})]}),S&&(0,X.jsx)(`p`,{role:`status`,children:S})]})}async function Oe(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,signal:t,headers:n?{"Content-Type":`application/json`}:void 0,body:n?JSON.stringify(n):void 0}),a=await i.json();if(!i.ok)throw Error(a.error??`HTTP ${i.status}`);return a}function ke({bots:e,preferredBotId:t,onSaved:n}){let r=D(a().locale),[i,o]=(0,J.useState)(t??e[0]?.id??``),[s,c]=(0,J.useState)(null),[l,u]=(0,J.useState)(``),[d,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(``),[_,v]=(0,J.useState)(0),y=(0,J.useRef)(null);(0,J.useEffect)(()=>{!i&&e.length&&o(t??e[0].id)},[i,e,t]);let b=e.find(e=>e.id===i),x=!!l&&!!b?.deviceId&&b.deviceId!==l;(0,J.useEffect)(()=>{let e=new AbortController;return y.current=e,m(!1),c(null),g(``),(async()=>{let t=await Oe(`chat-status`,e.signal);if(u(t.deviceId??``),!i||b?.deviceId&&t.deviceId!==b.deviceId)return;let n=await Oe(`local-bots/${encodeURIComponent(i)}`,e.signal);e.signal.aborted||c(n.bot)})().catch(t=>{e.signal.aborted||g(t.message)}),()=>e.abort()},[i,b?.deviceId,_]);async function S(){let e=y.current;if(s&&!x&&d.trim()&&e&&!e.signal.aborted){m(!0),g(``);try{let t=await Oe(`local-bots/${encodeURIComponent(s.id)}/preset`,e.signal,{revision:s.revision,preset:JSON.parse(d)});if(e.signal.aborted)return;c(t.bot),n(),g(`${r?`已保存新版本`:`Saved revision`} v${t.bot.revision}${t.synced?``:r?`;Hub同步待重试`:`; Hub sync pending`}`)}catch(t){e.signal.aborted||g(t.message)}finally{e.signal.aborted||m(!1)}}}return(0,X.jsxs)(`details`,{className:`group-ecosystem-panel`,children:[(0,X.jsx)(`summary`,{children:r?`Bot 配置与预设`:`Bot configuration and presets`}),(0,X.jsxs)(`label`,{children:[`Bot`,(0,X.jsxs)(`select`,{value:i,disabled:p,onChange:e=>o(e.target.value),children:[(0,X.jsx)(`option`,{value:``,children:r?`选择 Bot`:`Select Bot`}),e.map(e=>(0,X.jsx)(`option`,{value:e.id,children:e.name},e.id))]})]}),(0,X.jsx)(`p`,{children:r?`仅编辑本机 Bot。保存创建新 revision;忙碌的 Bot 会拒绝修改,在途任务不热改。`:`Edit local Bots only. Saving creates a new revision. Busy Bots reject edits; in-flight tasks retain their configuration.`}),x&&(0,X.jsx)(`p`,{role:`status`,children:r?`此 Bot 在远程设备。请在该设备的本机界面读取和保存配置。`:`This Bot belongs to a remote device. Read and save its configuration in that device's local UI.`}),s&&!x&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{children:[s.name,` · v`,s.revision,` · `,s.cwd]}),(0,X.jsxs)(`p`,{children:[r?`模型`:`Model`,`:`,` `,s.model?`${s.model.provider}/${s.model.modelId}`:r?`跟随设备默认`:`Device default`]}),(0,X.jsxs)(`p`,{children:[r?`已授权工具`:`Authorized tools`,`: `,s.tools.join(`, `)||(r?`无`:`None`)]}),(0,X.jsxs)(`label`,{children:[r?`可选预设 JSON(仅填写要修改的字段)`:`Optional preset JSON (include only fields to change)`,(0,X.jsx)(`textarea`,{rows:6,value:d,onChange:e=>f(e.target.value),placeholder:`{"systemPrompt":"…"}`})]}),(0,X.jsx)(`p`,{children:r?`允许字段:model、tools、skills、mcpServers、systemPrompt。省略字段保留当前值;工具、技能、MCP及模型须在本机目录中可用。`:`Allowed fields: model, tools, skills, mcpServers, systemPrompt. Omitted fields retain current values. Tools, skills, MCP and models must be available locally.`}),(0,X.jsx)(`button`,{className:`btn`,disabled:p,onClick:()=>v(e=>e+1),children:r?`重新读取配置`:`Reload configuration`}),(0,X.jsx)(`button`,{className:`btn primary`,disabled:p||!d.trim(),onClick:()=>void S(),children:r?`保存为新 revision(基于 v${s.revision})`:`Save new revision (based on v${s.revision})`})]}),h&&(0,X.jsx)(`p`,{role:`status`,children:h})]})}var Ae=[{id:`architecture`,titleZh:`架构设计`,titleEn:`Architecture`,aliases:[`架构设计`,`系统架构`,`architecture`,`system architecture`,`架构契约`,`技术方案`]},{id:`contracts`,titleZh:`接口契约`,titleEn:`Contracts`,aliases:[`接口契约`,`接口规范`,`contracts`,`api contracts`,`api规范`,`协议契约`,`数据契约`]},{id:`progress`,titleZh:`任务分工`,titleEn:`Task Progress`,aliases:[`任务分工`,`分工与进度`,`progress`,`tasks`,`task progress`,`流水线分工`,`任务流水线`]},{id:`blockers`,titleZh:`阻塞与决策`,titleEn:`Blockers & Decisions`,aliases:[`阻塞与决策`,`决策记录`,`blockers`,`decisions`,`风险与阻塞`,`关键技术决策`]}];function je(e){if(!e||!e.trim())return{preamble:``,sections:[]};let t=e.split(/\r?\n/),n=[],r=``,i=``,a=[],o=[],s=!1;for(let e of t){let t=e.match(/^##\s+(.+)$/);if(t){let o=t[1].trim();s?(n.push({id:Me(r),title:r,content:a.join(`
|
|
5
5
|
`).trim(),rawHeader:i}),a=[]):s=!0,r=o,i=e;continue}s?a.push(e):o.push(e)}return s&&r&&n.push({id:Me(r),title:r,content:a.join(`
|
|
6
6
|
`).trim(),rawHeader:i}),{preamble:o.join(`
|
|
7
7
|
`).trim(),sections:n}}function Me(e){let t=e.toLowerCase();for(let e of Ae)if(e.aliases.some(e=>t.includes(e.toLowerCase())))return e.id;return`custom-${encodeURIComponent(e.slice(0,32))}`}function Ne(e,t,n,r){let{preamble:i,sections:a}=je(e),o=a.findIndex(e=>e.id===t);o>=0?a[o].content=r.trim():a.push({id:t,title:n,content:r.trim(),rawHeader:`## ${n}`});let s=[];i&&s.push(i);for(let e of a)e.rawHeader?s.push(e.rawHeader):s.push(`## ${e.title}`),e.content&&s.push(e.content);return s.join(`
|
|
@@ -58,4 +58,4 @@ e.g.
|
|
|
58
58
|
|
|
59
59
|
e.g.
|
|
60
60
|
- Decision: Use SSE instead of polling
|
|
61
|
-
- Blocker: Missing device driver`;default:return d?`在此输入该分区的 Markdown 格式内容...`:`Enter Markdown content for this section...`}})(p),value:E,onChange:e=>k(e.target.value),disabled:A})]})}):(0,X.jsx)(`div`,{className:`dg-blackboard-content`,children:p===`all`?(0,X.jsxs)(X.Fragment,{children:[i?.title&&(0,X.jsx)(`h3`,{className:`dg-blackboard-title`,children:i.title}),i?.content?(0,X.jsx)(`div`,{className:`dg-blackboard-markdown`,children:(0,X.jsx)(te,{text:i.content})}):(0,X.jsxs)(`div`,{className:`dg-blackboard-empty`,children:[(0,X.jsx)(y,{style:{fontSize:32,opacity:.4,marginBottom:8}}),(0,X.jsx)(`p`,{children:d?`当前群组黑板为空。点击右上角“编辑共识”为所有协作 Bot 确立技术架构契约与长期记忆。`:`Blackboard is empty. Click 'Edit All' to set shared contracts and long-term memory.`})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dg-bb-section-header`,children:(0,X.jsx)(`h4`,{className:`dg-bb-section-title`,children:V?d?V.titleZh:V.titleEn:B?.title||p})}),B?.content?(0,X.jsx)(`div`,{className:`dg-blackboard-markdown`,children:(0,X.jsx)(te,{text:B.content})}):(0,X.jsxs)(`div`,{className:`dg-blackboard-empty`,children:[(0,X.jsx)(y,{style:{fontSize:32,opacity:.4,marginBottom:8}}),(0,X.jsx)(`p`,{children:d?`该分区当前尚无记录内容。点击右上角“编辑此分区”快速添加共识与规则。`:`No content in this section yet. Click 'Edit Section' to add consensus and specifications.`})]})]})})]})}var Fe=[{id:`message`,zh:`新群聊消息`,en:`New message`},{id:`task_completed`,zh:`Bot 任务成功完成`,en:`Task completed`},{id:`task_failed`,zh:`Bot 任务执行失败`,en:`Task failed`},{id:`delivery`,zh:`Bot 代码交付提交`,en:`Code delivery`}];function Ie({roomId:e,disabled:n=!1}){let{locale:i}=a(),u=D(i),[d,f]=(0,J.useState)([]),[p,h]=(0,J.useState)(!0),[g,y]=(0,J.useState)(``),[b,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(``),[O,N]=(0,J.useState)(``),[P,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(``),[R,z]=(0,J.useState)(!1),[B,V]=(0,J.useState)(`hub`),[H,U]=(0,J.useState)(null),[ee,te]=(0,J.useState)(null),[ne,W]=(0,J.useState)(null),G=(0,J.useRef)(null),K=async()=>{G.current&&G.current.abort();let t=new AbortController;G.current=t;try{y(``);let[n,i,a]=await Promise.all([fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks`)),{signal:t.signal}),fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}`)),{signal:t.signal}).catch(()=>null),fetch(r(o(`/api/device-center/status`)),{signal:t.signal}).catch(()=>null)]);if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}let s=await n.json();if(f(s.webhooks||[]),i&&i.ok){let e=(await i.json()).room?.hubRelayBaseUrl||``;N(e),L(e)}if(a&&a.ok){let e=await a.json();e.hubUrl&&E(e.hubUrl)}}catch(e){t.signal.aborted||y(e?.message||(u?`加载 Webhooks 失败`:`Failed to load webhooks`))}finally{t.signal.aborted||h(!1)}};(0,J.useEffect)(()=>(h(!0),K(),()=>{G.current&&G.current.abort()}),[e]);let re=O||T||window.location.origin,q=async()=>{z(!0),y(``);try{let t=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/hub-relay`)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hubRelayBaseUrl:I.trim()||null})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to update Hub relay base URL`)}N(I.trim()),F(!1)}catch(e){y(e?.message||`Failed to save Hub relay URL`)}finally{z(!1)}},ie=(e,t)=>{navigator.clipboard.writeText(e),U(t),setTimeout(()=>U(null),2e3)},ae=async t=>{try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}`)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!t.enabled})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Update failed`)}await K()}catch(e){y(e?.message||`Failed to update webhook`)}},oe=async t=>{if(window.confirm(u?`确定要删除该 Webhook 吗?`:`Are you sure you want to delete this webhook?`))try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}/delete`)),{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Delete failed`)}await K()}catch(e){y(e?.message||`Failed to delete webhook`)}},se=async t=>{if(window.confirm(u?`重新生成 Token 将使旧 Token 立即失效,依赖此 URL 的外部服务需要同步更新。确定重新生成?`:`Regenerating the token will invalidate the old one immediately. Continue?`))try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}/regenerate-token`)),{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Regenerate failed`)}await K()}catch(e){y(e?.message||`Failed to regenerate token`)}},ce=async t=>{te(t.id),W(null);try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}/test`)),{method:`POST`}),i=await n.json().catch(()=>({}));if(n.ok&&i.success){let e=t.relayViaHub===!1?``:u?` [Hub中转]`:` [via Hub]`;W({id:t.id,success:!0,message:u?`推送成功${e} (HTTP ${i.status??200})`:`Delivered successfully${e} (HTTP ${i.status??200})`})}else W({id:t.id,success:!1,message:i.error||(u?`推送测试失败`:`Test failed`)})}catch(e){W({id:t.id,success:!1,message:e?.message||`Network request failed`})}finally{te(null)}},le=d.filter(e=>e.type===`incoming`),ue=d.filter(e=>e.type===`outgoing`);return(0,X.jsxs)(`div`,{className:`group-webhooks-container`,children:[(0,X.jsxs)(`div`,{className:`group-webhooks-header`,children:[(0,X.jsx)(`div`,{className:`group-webhooks-desc`,children:(0,X.jsx)(`p`,{children:u?`群组 Webhook 支持双向通信与可选 Hub 中转:入站可使用公网 Hub 中转地址接收外部事件唤醒 Bot;出站通知可选由 Hub 服务端中转代发。`:`Two-way Webhooks with optional Hub relay: incoming uses Hub public relay endpoints, outgoing supports relaying via Hub.`})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary group-webhooks-add-btn`,disabled:n,onClick:()=>{w(null),S(!0)},children:[(0,X.jsx)(c,{}),(0,X.jsx)(`span`,{children:u?`新建 Webhook`:`Add Webhook`})]})]}),g&&(0,X.jsxs)(`div`,{className:`group-webhooks-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:g})]}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-bar`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-relay-info`,children:[(0,X.jsx)(j,{className:`icon-hub`}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-text`,children:[(0,X.jsx)(`strong`,{children:u?`Hub 中转基准地址:`:`Hub Relay Base URL:`}),(0,X.jsx)(`code`,{children:re}),O&&(0,X.jsx)(`span`,{className:`badge-custom`,children:u?`自定义`:`Custom`})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,onClick:()=>F(!P),title:u?`配置自定义 Hub 中转基准域名`:`Configure Hub relay base URL`,children:[(0,X.jsx)(A,{}),(0,X.jsx)(`span`,{children:u?`设置中转域名`:`Relay URL`})]})]}),P&&(0,X.jsx)(`div`,{className:`group-webhook-relay-config-box`,children:(0,X.jsxs)(`div`,{className:`group-webhook-relay-config-fields`,children:[(0,X.jsx)(`label`,{children:u?`若 Hub 位于公网反向代理或具有独立域名,请输入对外公开的完整基准地址(如 https://hub.example.com):`:`Specify the public Hub URL (e.g. https://hub.example.com) if behind a reverse proxy:`}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-input-row`,children:[(0,X.jsx)(`input`,{type:`url`,className:`input`,placeholder:`https://hub.example.com`,value:I,onChange:e=>L(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,disabled:R,onClick:q,children:R?u?`保存中…`:`Saving...`:u?`保存中转地址`:`Save`}),O&&(0,X.jsx)(`button`,{type:`button`,className:`btn secondary sm`,disabled:R,onClick:()=>{L(``),q()},children:u?`重置`:`Reset`})]})]})}),p?(0,X.jsx)(`div`,{className:`group-webhooks-loading`,children:u?`正在加载 Webhook 列表…`:`Loading webhooks...`}):d.length===0?(0,X.jsxs)(`div`,{className:`group-webhooks-empty`,children:[(0,X.jsx)(`div`,{className:`group-webhooks-empty-icon`,children:`🔗`}),(0,X.jsx)(`h4`,{children:u?`暂未配置群组 Webhook`:`No Webhooks Configured`}),(0,X.jsx)(`p`,{children:u?`点击上方「新建 Webhook」创建入站或出站自动化集成。`:`Click 'Add Webhook' above to create incoming or outgoing automations.`})]}):(0,X.jsxs)(`div`,{className:`group-webhooks-list`,children:[le.length>0&&(0,X.jsxs)(`div`,{className:`group-webhooks-section`,children:[(0,X.jsxs)(`div`,{className:`group-webhooks-section-header`,children:[(0,X.jsxs)(`h4`,{className:`group-webhooks-section-title`,children:[(0,X.jsx)(M,{className:`icon-incoming`}),(0,X.jsx)(`span`,{children:u?`入站 Webhook (Incoming)`:`Incoming Webhooks`}),(0,X.jsx)(`span`,{className:`badge`,children:le.length})]}),(0,X.jsxs)(`div`,{className:`group-webhook-mode-toggle`,title:u?`选择生成中转还是直连地址`:`Select address mode`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mode-btn ${B===`hub`?`active`:``}`,onClick:()=>V(`hub`),children:[`🌐 `,u?`Hub 中转地址`:`Hub Relay`]}),(0,X.jsxs)(`button`,{type:`button`,className:`mode-btn ${B===`direct`?`active`:``}`,onClick:()=>V(`direct`),children:[`💻 `,u?`本地直连地址`:`Direct`]})]})]}),(0,X.jsx)(`div`,{className:`group-webhooks-cards`,children:le.map(r=>{let i=`${B===`hub`?re:window.location.origin}/api/rooms/${e}/webhooks/incoming/${r.id}?token=${r.token}`,a=`curl -X POST "${i}" -H "Content-Type: application/json" -d '{"text":"Hello from Webhook","senderName":"${r.name}"}'`;return(0,X.jsxs)(`div`,{className:`group-webhook-card ${r.enabled?`enabled`:`disabled`}`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-card-header`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-name-box`,children:[(0,X.jsx)(`strong`,{className:`group-webhook-name`,children:r.name}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${r.enabled?`badge-active`:`badge-inactive`}`,children:r.enabled?u?`已启用`:`Active`:u?`已暂停`:`Disabled`}),(0,X.jsx)(`span`,{className:`group-webhook-badge badge-relay`,children:B===`hub`?u?`🌐 Hub中转`:`🌐 Hub Relay`:u?`💻 本机直连`:`💻 Direct`}),r.allowBotTrigger!==!1&&(0,X.jsx)(`span`,{className:`group-webhook-badge badge-info`,title:u?`收到外部消息时自动触发群主管或被 @ 的 Bot`:`Triggers Bot execution`,children:u?`可唤醒 Bot`:`Triggers Bot`})]}),(0,X.jsxs)(`div`,{className:`group-webhook-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`编辑`:`Edit`,disabled:n,onClick:()=>{w(r),S(!0)},children:(0,X.jsx)(v,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle danger`,title:u?`删除`:`Delete`,disabled:n,onClick:()=>oe(r.id),children:(0,X.jsx)(k,{})}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":r.enabled,className:`set-switch ${r.enabled?`on`:``}`,disabled:n,onClick:()=>ae(r),title:u?`启用/禁用切换`:`Toggle status`,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsxs)(`label`,{children:[u?`Webhook 入站地址:`:`Webhook URL:`,(0,X.jsxs)(`span`,{className:`mode-indicator`,children:[`(`,B===`hub`?u?`外部经 Hub 中转打入`:`Forwarded via Hub`:u?`本地端口直通`:`Direct access`,`)`]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-url-row`,children:[(0,X.jsx)(`code`,{className:`group-webhook-code`,children:i}),(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,title:u?`复制 URL`:`Copy URL`,onClick:()=>ie(i,`url-${r.id}`),children:[H===`url-${r.id}`?(0,X.jsx)(t,{}):(0,X.jsx)(s,{}),(0,X.jsx)(`span`,{children:H===`url-${r.id}`?u?`已复制`:`Copied`:u?`复制`:`Copy`})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn secondary sm`,title:u?`重新生成安全凭证 Token`:`Regenerate Token`,disabled:n,onClick:()=>se(r.id),children:(0,X.jsx)(_,{})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`调用示例 (cURL):`:`cURL Example:`}),(0,X.jsxs)(`div`,{className:`group-webhook-curl-box`,children:[(0,X.jsx)(`code`,{children:a}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`复制 cURL`:`Copy cURL`,onClick:()=>ie(a,`curl-${r.id}`),children:H===`curl-${r.id}`?(0,X.jsx)(t,{}):(0,X.jsx)(s,{})})]})]})]},r.id)})})]}),ue.length>0&&(0,X.jsxs)(`div`,{className:`group-webhooks-section`,children:[(0,X.jsxs)(`h4`,{className:`group-webhooks-section-title`,children:[(0,X.jsx)(m,{className:`icon-outgoing`}),(0,X.jsx)(`span`,{children:u?`出站 Webhook (Outgoing)`:`Outgoing Webhooks`}),(0,X.jsx)(`span`,{className:`badge`,children:ue.length})]}),(0,X.jsx)(`div`,{className:`group-webhooks-cards`,children:ue.map(e=>{let r=ee===e.id,i=ne?.id===e.id?ne:null,a=e.relayViaHub!==!1;return(0,X.jsxs)(`div`,{className:`group-webhook-card ${e.enabled?`enabled`:`disabled`}`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-card-header`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-name-box`,children:[(0,X.jsx)(`strong`,{className:`group-webhook-name`,children:e.name}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${e.enabled?`badge-active`:`badge-inactive`}`,children:e.enabled?u?`已启用`:`Active`:u?`已暂停`:`Disabled`}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${a?`badge-relay`:`badge-direct`}`,title:a?u?`由 Hub 服务器统一代理出网外发`:`Relayed via Hub server`:u?`由本地设备节点直连外发`:`Direct connection from device`,children:a?u?`🌐 Hub中转代发`:`🌐 Hub Relay`:u?`💻 本地直连外发`:`💻 Direct Outbound`}),e.secret?(0,X.jsx)(`span`,{className:`group-webhook-badge badge-secret`,title:u?`已配置 HMAC-SHA256 签名校验密钥`:`HMAC secret configured`,children:u?`带签名`:`Signed`}):null]}),(0,X.jsxs)(`div`,{className:`group-webhook-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,disabled:n||r,onClick:()=>ce(e),title:u?`向目标地址发送一条测试 Ping`:`Send test ping`,children:[(0,X.jsx)(l,{}),(0,X.jsx)(`span`,{children:r?u?`测试中…`:`Testing...`:u?`测试`:`Test`})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`编辑`:`Edit`,disabled:n,onClick:()=>{w(e),S(!0)},children:(0,X.jsx)(v,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle danger`,title:u?`删除`:`Delete`,disabled:n,onClick:()=>oe(e.id),children:(0,X.jsx)(k,{})}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:`set-switch ${e.enabled?`on`:``}`,disabled:n,onClick:()=>ae(e),title:u?`启用/禁用切换`:`Toggle status`,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`目标推送 URL:`:`Target URL:`}),(0,X.jsx)(`code`,{className:`group-webhook-code`,children:e.url})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`订阅事件:`:`Subscribed Events:`}),(0,X.jsx)(`div`,{className:`group-webhook-event-chips`,children:(e.events||[`message`,`task_completed`,`task_failed`,`delivery`]).map(e=>{let t=Fe.find(t=>t.id===e);return(0,X.jsx)(`span`,{className:`group-webhook-event-chip`,children:t?u?t.zh:t.en:e},e)})})]}),i&&(0,X.jsxs)(`div`,{className:`group-webhook-test-result ${i.success?`success`:`failed`}`,children:[i.success?(0,X.jsx)(t,{}):(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:i.message})]})]},e.id)})})]})]}),b&&(0,X.jsx)(Le,{roomId:e,webhook:C,onClose:()=>{S(!1),w(null)},onSaved:async()=>{S(!1),w(null),await K()}})]})}function Le({roomId:e,webhook:t,onClose:n,onSaved:i}){let{locale:s}=a(),c=D(s),l=!!t,[u,d]=(0,J.useState)(t?.name||``),[f,p]=(0,J.useState)(t?.type||`incoming`),[m,h]=(0,J.useState)(!t||t.enabled),[g,_]=(0,J.useState)(!t||t.allowBotTrigger!==!1),[v,y]=(0,J.useState)(!t||t.relayViaHub!==!1),[b,S]=(0,J.useState)(t?.url||``),[C,w]=(0,J.useState)(t?.secret||``),[T,E]=(0,J.useState)(t?.events||[`message`,`task_completed`,`task_failed`,`delivery`]),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(``),M=async n=>{if(n.preventDefault(),!u.trim()){j(c?`请输入 Webhook 名称`:`Name is required`);return}if(f===`outgoing`&&(!b.trim()||!/^https?:\/\/.+/i.test(b.trim()))){j(c?`请输入有效的 http:// 或 https:// 目标地址`:`Valid HTTP/HTTPS URL is required`);return}k(!0),j(``);try{let n={name:u.trim(),enabled:m};l||(n.type=f),f===`incoming`?n.allowBotTrigger=g:(n.url=b.trim(),n.secret=C.trim()||void 0,n.events=T,n.relayViaHub=v);let a=l?`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}`:`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks`,s=await fetch(r(o(a)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||`Save failed`)}i()}catch(e){j(e?.message||`Failed to save webhook`)}finally{k(!1)}},N=e=>{if(T.includes(e)){if(T.length===1)return;E(T.filter(t=>t!==e))}else E([...T,e])};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`group-webhook-modal-dialog`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,X.jsxs)(`div`,{className:`gwm-header`,children:[(0,X.jsxs)(`div`,{className:`gwm-title-box`,children:[(0,X.jsxs)(`h3`,{children:[(0,X.jsx)(`span`,{className:`gwm-title-icon`,children:`🔗`}),` `,l?c?`编辑 Webhook`:`Edit Webhook`:c?`新建 Webhook`:`New Webhook`]}),(0,X.jsx)(`p`,{className:`gwm-subtitle`,children:c?`配置入站自动化触发或出站事件广播通知`:`Configure incoming automations or outgoing event notifications`})]}),(0,X.jsx)(`button`,{type:`button`,className:`gwm-close-btn`,onClick:n,"aria-label":c?`关闭`:`Close`,title:c?`关闭`:`Close`,children:`✕`})]}),(0,X.jsxs)(`form`,{onSubmit:M,children:[(0,X.jsxs)(`div`,{className:`gwm-body`,children:[A&&(0,X.jsxs)(`div`,{className:`group-webhooks-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:A})]}),!l&&(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{className:`gwm-label`,children:c?`集成类型`:`Integration Type`}),(0,X.jsxs)(`div`,{className:`gwm-type-cards`,children:[(0,X.jsxs)(`div`,{className:`gwm-type-card ${f===`incoming`?`selected`:``}`,onClick:()=>p(`incoming`),role:`button`,tabIndex:0,children:[(0,X.jsx)(`span`,{className:`gwm-type-check`,children:`✓`}),(0,X.jsxs)(`div`,{className:`gwm-type-card-head`,children:[(0,X.jsx)(`span`,{className:`gwm-type-icon incoming`,children:`📥`}),(0,X.jsx)(`span`,{className:`gwm-type-name`,children:c?`入站 Webhook`:`Incoming Webhook`})]}),(0,X.jsx)(`p`,{className:`gwm-type-desc`,children:c?`外部系统推送消息进群,可自动指派或唤醒群内 Bot 执行任务`:`External services push messages to this group & trigger Bots`})]}),(0,X.jsxs)(`div`,{className:`gwm-type-card ${f===`outgoing`?`selected`:``}`,onClick:()=>p(`outgoing`),role:`button`,tabIndex:0,children:[(0,X.jsx)(`span`,{className:`gwm-type-check`,children:`✓`}),(0,X.jsxs)(`div`,{className:`gwm-type-card-head`,children:[(0,X.jsx)(`span`,{className:`gwm-type-icon outgoing`,children:`📤`}),(0,X.jsx)(`span`,{className:`gwm-type-name`,children:c?`出站 Webhook`:`Outgoing Webhook`})]}),(0,X.jsx)(`p`,{className:`gwm-type-desc`,children:c?`将新消息、任务完成、失败或交付等事件实时推送至外部服务`:`Forward messages, task completions, and deliveries to external endpoints`})]})]})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-name`,className:`gwm-label`,children:c?`Webhook 名称`:`Webhook Name`}),(0,X.jsx)(`input`,{id:`webhook-name`,type:`text`,className:`gwm-input`,placeholder:c?`例如:GitHub Actions CI、监控告警、飞书群通知`:`e.g. GitHub Actions CI, Sentry Alerts`,value:u,maxLength:80,onChange:e=>d(e.target.value),autoFocus:!0})]}),f===`incoming`?(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>_(!g),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`收到外部推送时唤醒 Bot 执行任务`:`Allow incoming messages to trigger Bots`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`检测到消息包含 @Bot 或群组设有群主管时,自动生成任务派发`:`Triggers coordinator or mentioned Bots automatically`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:`set-switch ${g?`on`:``}`,onClick:e=>{e.stopPropagation(),_(!g)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-url`,className:`gwm-label`,children:c?`目标推送 URL`:`Target Endpoint URL`}),(0,X.jsx)(`input`,{id:`webhook-url`,type:`url`,className:`gwm-input`,placeholder:`https://example.com/webhook/endpoint`,value:b,onChange:e=>S(e.target.value)}),(0,X.jsx)(`span`,{className:`gwm-field-hint`,children:c?`事件触发时,系统将以 HTTP POST 发送 JSON 格式载荷至此地址。`:`Delivered as HTTP POST with JSON content.`})]}),(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>y(!v),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`通过 Hub 服务端中转代发 (Relay via Hub)`:`Relay via Hub Server`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`由 Hub 服务器统一作为代理外发通知(固定出口 IP);若目标是局域网私有地址请关闭`:`Dispatched centrally by Hub. Uncheck if target is internal LAN address.`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":v,className:`set-switch ${v?`on`:``}`,onClick:e=>{e.stopPropagation(),y(!v)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-secret`,className:`gwm-label`,children:c?`签名密钥 Secret(可选)`:`HMAC Secret (Optional)`}),(0,X.jsx)(`input`,{id:`webhook-secret`,type:`text`,className:`gwm-input`,placeholder:c?`可选密钥,用于生成 X-Pi-Signature 请求头防篡改校验`:`Optional secret used for X-Pi-Signature header`,value:C,maxLength:256,onChange:e=>w(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{className:`gwm-label`,children:c?`订阅事件`:`Subscribed Events`}),(0,X.jsx)(`div`,{className:`gwm-events-grid`,children:Fe.map(e=>(0,X.jsxs)(`div`,{className:`gwm-event-chip ${T.includes(e.id)?`active`:``}`,onClick:()=>N(e.id),children:[(0,X.jsx)(`span`,{className:`gwm-chip-box`,children:T.includes(e.id)?`✓`:``}),(0,X.jsx)(`span`,{children:c?e.zh:e.en})]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>h(!m),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`立即启用该 Webhook`:`Enable this Webhook`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`创建完成后立即生效并接受/分发事件`:`Active immediately upon save`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":m,className:`set-switch ${m?`on`:``}`,onClick:e=>{e.stopPropagation(),h(!m)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`gwm-footer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,onClick:n,disabled:O,children:c?`取消`:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:O,children:O?c?`保存中…`:`Saving...`:l?c?`保存修改`:`Save Changes`:c?`创建 Webhook`:`Create Webhook`})]})]})]})})}var Re=()=>{},ze=(0,J.memo)(function({isOpen:e,activeTab:t,onClose:n,roomId:r,detail:i,devices:o,members:s,conversations:c,attentionCount:l,disabled:u,conversationError:d,onRefreshGroup:f,onRefreshConversations:p}){let{locale:m}=a(),h=D(m);if((0,J.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&n()};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n]),!e)return null;let g={router:{icon:`🧭`,title:h?`群组 AI Router`:`Group AI Router`},"work-items":{icon:`🗂`,title:h?`群组工单与 Router 运行`:`Work Items & Router Runs`},blackboard:{icon:`📋`,title:h?`群组共享共识黑板`:`Group Shared Blackboard`,badge:i?.room.blackboard?.version},deliveries:{icon:`📦`,title:h?`交付与待办事项`:`Deliveries & Attention`,badge:l>0?l:c.length>0?c.length:void 0},transfers:{icon:`📁`,title:h?`跨机大文件传输与断点续传`:`Cross-Device File Transfers`},canvas:{icon:`🎨`,title:h?`群画布工作流`:`Group Canvas Workflow`},presets:{icon:`🤖`,title:h?`Bot 预设与规则配置`:`Bot Presets & Settings`},bots:{icon:`👥`,title:h?`群协作 Bot 成员清单`:`Collaborating Bots`,badge:s.length},webhooks:{icon:`🔗`,title:h?`群组 Webhook 集成`:`Group Webhooks`,badge:i?.room.webhooks?.filter(e=>e.enabled).length}}[t]||{icon:`📦`,title:h?`群协同`:`Collaboration`};return(0,X.jsxs)(`div`,{className:`group-drawer-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":g.title,children:[(0,X.jsx)(`div`,{className:`group-drawer-backdrop`,onClick:n,"aria-hidden":!0}),(0,X.jsxs)(`aside`,{className:`group-drawer-panel`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`group-drawer-header`,children:[(0,X.jsxs)(`div`,{className:`group-drawer-title-box`,children:[(0,X.jsx)(`span`,{className:`group-drawer-title-icon`,children:g.icon}),(0,X.jsx)(`h3`,{className:`group-drawer-title`,children:g.title}),g.badge!==void 0&&g.badge>0&&(0,X.jsx)(`span`,{className:`group-drawer-badge ${t===`deliveries`&&l>0?`attention`:``}`,children:g.badge})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn group-drawer-close-btn`,onClick:n,title:h?`关闭抽屉 (Esc)`:`Close Drawer (Esc)`,"aria-label":h?`关闭`:`Close`,children:(0,X.jsx)(w,{})})]}),(0,X.jsxs)(`div`,{className:`group-drawer-body`,children:[t===`router`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(G,{roomId:r,router:i?.room.router,disabled:u,onSaved:f??Re},r)}),t===`work-items`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(K,{roomId:r,tasks:i?.tasks,disabled:u,onChanged:f},r)}),t===`blackboard`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Pe,{roomId:r,blackboard:i?.room.blackboard,disabled:u,onSaved:f??Re})}),t===`deliveries`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(me,{roomId:r,conversations:c,bots:o,disabled:u,error:d,onRefresh:p})}),t===`transfers`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Se,{roomId:r,bots:o,disabled:u})}),t===`canvas`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(De,{roomId:r,binding:i?.room.canvasBinding,onSaved:f??Re})}),t===`presets`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(ke,{bots:s,onSaved:f??Re})}),t===`webhooks`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Ie,{roomId:r,disabled:u})}),t===`bots`&&(0,X.jsxs)(`div`,{className:`group-drawer-pane group-members-overview`,children:[(0,X.jsxs)(`div`,{className:`grp-section-title`,children:[(0,X.jsx)(`span`,{children:h?`群协作 Bot 成员清单`:`Collaborating Bots`}),(0,X.jsxs)(`span`,{className:`grp-count`,children:[`(`,s.length,`)`]})]}),(0,X.jsx)(`div`,{className:`grp-bot-list`,children:s.map(e=>(0,X.jsxs)(`div`,{className:`grp-bot-card`,children:[(0,X.jsxs)(`div`,{className:`grp-bot-card-top`,children:[(0,X.jsxs)(`div`,{className:`grp-bot-title`,children:[(0,X.jsx)(`span`,{className:`grp-bot-indicator ${e.online===!1?`offline`:`online`}`}),(0,X.jsx)(`strong`,{children:e.name}),!i?.room.router?.enabled&&e.id===i?.room.primaryBotId&&(0,X.jsx)(`span`,{className:`grp-primary-badge`,children:h?`主协调`:`Primary`})]}),(0,X.jsx)(`span`,{className:`grp-bot-status-text`,children:e.online===!1?h?`离线`:`Offline`:h?`在线就绪`:`Online Ready`})]}),(0,X.jsxs)(`div`,{className:`grp-bot-info`,children:[e.deviceName&&(0,X.jsxs)(`div`,{className:`grp-bot-device`,children:[(0,X.jsxs)(`span`,{children:[`🖥 `,h?`设备: `:`Device: `]}),(0,X.jsx)(`code`,{children:e.deviceName})]}),(0,X.jsxs)(`div`,{className:`grp-bot-id`,children:[(0,X.jsx)(`span`,{children:`ID: `}),(0,X.jsx)(`code`,{title:e.id,children:e.id})]})]}),e.tools&&e.tools.length>0&&(0,X.jsxs)(`div`,{className:`grp-bot-tools`,children:[(0,X.jsx)(`span`,{className:`grp-tools-label`,children:h?`授权工具: `:`Tools: `}),(0,X.jsx)(`div`,{className:`grp-tools-chips`,children:e.tools.map(e=>(0,X.jsx)(`span`,{className:`grp-tool-chip`,children:e},e))})]})]},e.id))})]})]})]})]})}),Be=[{id:`summarize-finish`,labelZh:`直接汇总当前阶段产物并结束`,labelEn:`Summarize & Finish`,textZh:`直接汇总当前阶段产物并结束,保留关键交付物与验证结论。`,textEn:`Directly summarize current phase deliverables and finish, retaining key evidence and conclusions.`},{id:`check-types`,labelZh:`优先检查并补充类型声明`,labelEn:`Prioritize Types`,textZh:`优先检查并补充缺失的类型声明,确保 strict typecheck 零错误。`,textEn:`Prioritize checking and adding type declarations to ensure zero typecheck errors.`},{id:`self-test`,labelZh:`先进行自测并展示通过证据`,labelEn:`Self-test & Show Evidence`,textZh:`先进行自测并展示通过证据,包括具体的测试用例与终端运行输出。`,textEn:`Run self-tests first and present verification evidence including test cases and terminal output.`},{id:`concise-report`,labelZh:`精简输出与风险`,labelEn:`Concise Output & Risks`,textZh:`精简后续输出,跳过冗余细节,仅汇报核心变更、未决风险与阻碍项。`,textEn:`Keep subsequent output concise; report only core changes, unresolved risks, and blockers.`}];function Ve({task:e,botName:n,deviceName:r,onClose:i,onSubmit:o}){let{locale:s}=a(),c=D(s),[l,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null),v=(0,J.useRef)(null);(0,J.useEffect)(()=>{v.current?.focus()},[]);let y=(0,J.useCallback)(e=>{let t=c?e.textZh:e.textEn;f(e=>e.trim()?`${e.trim()}\n${t}`:t),v.current?.focus()},[c]),b=(0,J.useCallback)(async()=>{let e=l.trim();if(!e){g(c?`请输入转向纠偏指令`:`Please enter steering instruction`);return}m(!0),g(null);try{await o(e),i()}catch(e){g(e?.message||(c?`注入转向指令失败`:`Failed to inject steering instruction`))}finally{m(!1)}},[l,o,i,c]),S=(0,J.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),b())},[b]),w=R(e.text),T=n||e.botId,E=r||e.deviceId;return(0,X.jsx)(U,{open:!0,onClose:i,title:c?`任务飞行中实时转向 (In-flight Steering)`:`In-flight Task Steering`,icon:(0,X.jsx)(d,{className:`dg-steer-icon`}),className:`dg-steer-modal`,children:(0,X.jsxs)(`div`,{className:`dg-steer-body`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-target-card`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-target-header`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-bot-badge`,children:[(0,X.jsx)(u,{style:{marginRight:4}}),(0,X.jsxs)(`strong`,{children:[`@`,T]})]}),E&&(0,X.jsx)(`span`,{className:`dg-steer-device-name`,title:c?`目标设备`:`Target Device`,children:E}),(0,X.jsxs)(`span`,{className:`dg-steer-task-id`,title:e.id,children:[`#`,e.id.slice(0,8)]})]}),(0,X.jsxs)(`div`,{className:`dg-steer-target-text`,title:w,children:[(0,X.jsx)(`span`,{className:`dg-steer-text-label`,children:c?`当前目标:`:`Current Goal: `}),w]}),e.progress?.phase&&(0,X.jsxs)(`div`,{className:`dg-steer-progress-tag`,children:[(0,X.jsx)(`span`,{className:`dg-steer-progress-dot`}),(0,X.jsxs)(`span`,{children:[c?`阶段`:`Phase`,`: `,(0,X.jsx)(`code`,{children:e.progress.phase}),e.progress.toolName&&` · Tool: ${e.progress.toolName}`]})]})]}),(0,X.jsxs)(`div`,{className:`dg-steer-presets-section`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-presets-header`,children:[(0,X.jsx)(C,{className:`dg-steer-zap-icon`}),(0,X.jsx)(`span`,{children:c?`常用纠偏预设(点击快速填入)`:`Quick Steering Presets`})]}),(0,X.jsx)(`div`,{className:`dg-steer-preset-chips`,children:Be.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`dg-steer-preset-chip`,onClick:()=>y(e),disabled:p,title:c?e.textZh:e.textEn,children:c?e.labelZh:e.labelEn},e.id))})]}),(0,X.jsxs)(`div`,{className:`dg-steer-input-section`,children:[(0,X.jsx)(`label`,{className:`dg-field-label`,children:c?`转向指令 (Ctrl+Enter 提交)`:`Steering Instruction (Ctrl+Enter to submit)`}),(0,X.jsx)(`textarea`,{ref:v,className:`dg-steer-textarea`,rows:4,placeholder:c?`例如:当前步骤已通过,请直接进行单元测试并汇报覆盖率;或者跳过重构,保持既有接口契约。`:`e.g. Current phase looks good, please jump to unit tests; or skip refactoring and adhere to contracts.`,value:l,onChange:e=>f(e.target.value),onKeyDown:S,disabled:p})]}),h&&(0,X.jsxs)(`div`,{className:`dg-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{style:{marginRight:6,flexShrink:0}}),(0,X.jsx)(`span`,{children:h})]}),(0,X.jsxs)(`div`,{className:`dg-steer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,onClick:i,disabled:p,children:c?`取消`:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:b,disabled:p||!l.trim(),children:[p?(0,X.jsx)(_,{className:`spin`,style:{marginRight:6}}):(0,X.jsx)(t,{style:{marginRight:6}}),p?c?`注入中...`:`Injecting...`:c?`发送转向指令`:`Inject Steering`]})]})]})})}function He(e,t,n=e=>new EventSource(e)){let r=!1,i=n(e),a=()=>!r&&t.alive();return i.onopen=()=>{a()&&(t.connected(!0),t.sync())},i.onerror=()=>{a()&&(t.connected(!1),t.sync())},i.addEventListener(`invalidate`,()=>{a()&&t.sync()}),i.addEventListener(`progress`,e=>{if(a())try{let n=JSON.parse(e.data);if(!n||[n.taskId,n.botId,n.attemptId].some(e=>typeof e!=`string`||!e||e.length>128)||!Number.isSafeInteger(n.sequence)||n.sequence<1||![`model`,`tool`,`waiting`].includes(n.phase)||n.text!==void 0&&(typeof n.text!=`string`||new TextEncoder().encode(n.text).byteLength>2048)||n.toolName!==void 0&&(typeof n.toolName!=`string`||!/^[A-Za-z0-9_.:-]{1,80}$/.test(n.toolName)))return;t.progress({taskId:n.taskId,botId:n.botId,attemptId:n.attemptId,sequence:n.sequence,phase:n.phase,...n.text===void 0?{}:{text:n.text},...n.toolName===void 0?{}:{toolName:n.toolName}})}catch{}}),()=>{r=!0,i.close()}}function Ue(e,t){return!!t&&e.status===`running`&&e.id===t.taskId&&e.botId===t.botId&&e.attemptId===t.attemptId}function We(e,t){return!e||e.attemptId!==t.attemptId||e.sequence<t.sequence}var $=null,Ge=new Set;function Ke(){for(let e of Ge)e()}function qe(e){if(!e){$!==null&&($=null,Ke());return}let t=!!($&&$.roomId===e.roomId),n=t&&$?$.activeRightTab:e.attentionCount>0?`deliveries`:`files`;$&&t&&$.detail===e.detail&&$.devices===e.devices&&$.members===e.members&&$.conversations===e.conversations&&$.attentionCount===e.attentionCount&&$.disabled===e.disabled&&$.conversationError===e.conversationError&&$.activeRightTab===n||($={...$,...e,activeRightTab:n},Ke())}var Je=class extends Error{status;code;constructor(e,t,n=``){super(t),this.status=e,this.code=n}};async function Ye(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(15e3)]),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Je(i.status,a.error||String(i.status),a.code??``);return a}var Xe=new Map,Ze=()=>{};function Qe({roomId:e,active:t=!0,onBack:n,uiHeaderSlots:r,uiActionSlots:i}){return(0,X.jsx)($e,{roomId:e,active:t,onBack:n,uiHeaderSlots:r,uiActionSlots:i},e)}function $e({roomId:e,active:t,onBack:n,uiHeaderSlots:i,uiActionSlots:s}){let{locale:c}=a(),l=D(c),[u,d]=(0,J.useState)(null),f=u?.bots??[],[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(0),[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)([]),[E,O]=(0,J.useState)(``),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(`deliveries`),N=(0,J.useCallback)(e=>{M(e),A(!0)},[]),P=(0,J.useCallback)(()=>{A(!1)},[]),[F,I]=(0,J.useState)(null),[R,U]=(0,J.useState)(null),ee=(0,J.useCallback)(()=>U(null),[]);function te(e){return e instanceof Je&&(e.status===404||e.status===403||e.status===409&&e.code===`REPAIR_REQUIRED`)}function G(e){return e instanceof Je&&e.status===409&&e.code===`REPAIR_REQUIRED`?l?`设备绑定已失效,请返回设备设置重新绑定。`:`Device binding expired. Return to device settings and bind again.`:e instanceof Error?e.message:String(e)}let K=(0,J.useRef)(0),re=(0,J.useRef)(null),q=(0,J.useRef)(null),ie=(0,J.useRef)(!1);(0,J.useEffect)(()=>{let n=++K.current,i=new Map,a=null,s=!1,c=!1,u=null,f=!1;async function p(){if(K.current!==n||!t||document.visibilityState===`hidden`)return;if(f){c=!0;return}c=!1,f=!0,u=new AbortController;let r=u.signal;try{let t=`rooms/${encodeURIComponent(e)}`,[a,o]=await Promise.allSettled([Ye(t,r),Ye(`${t}/conversations`,r)]);if(K.current!==n||r.aborted)return;if(o.status===`fulfilled`&&Array.isArray(o.value.conversations)?(T(o.value.conversations),O(``)):O(l?`无法更新对话列表,请稍后重试。`:`Could not refresh conversations. Try again shortly.`),a.status===`rejected`)throw a.reason;d({...a.value,tasks:a.value.tasks.map(e=>({...e,progress:Ue(e,i.get(e.id))?i.get(e.id):void 0}))});for(let e of i.keys())a.value.tasks.some(t=>Ue(t,i.get(e)))||i.delete(e);_(!1)}catch(e){if(K.current!==n||r.aborted)return;te(e)&&(d(null),_(!0)),m(G(e))}finally{f=!1,c&&K.current===n&&p()}}function h(){K.current===n&&t&&document.visibilityState!==`hidden`&&!a&&typeof EventSource<`u`&&(a=He(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/events`)),{alive:()=>K.current===n&&document.visibilityState!==`hidden`,sync:()=>{x(e=>e+1),p()},connected:e=>{s=e,C(e)},progress:e=>{let t=i.get(e.taskId);!We(t,e)||i.size>=128&&!t||(i.set(e.taskId,e),d(t=>t&&{...t,tasks:t.tasks.map(t=>Ue(t,e)?{...t,progress:e}:t)}))}}))}p(),h();let g=window.setInterval(()=>{s||p()},2e3),v=()=>{document.visibilityState===`hidden`?(u?.abort(),c=!1,a?.(),a=null,s=!1,C(!1)):(p(),h())};return document.addEventListener(`visibilitychange`,v),()=>{++K.current,C(!1),a?.(),u?.abort(),re.current?.abort(),clearInterval(g),document.removeEventListener(`visibilitychange`,v)}},[e,t,v]);let{state:ae,labels:oe}=(0,J.useMemo)(()=>{let t=u?.room.router?.enabled?{...u,room:{...u.room,primaryBotId:void 0}}:u,n=H(e,t,f,l),r=new Set((u?.messages??[]).filter(e=>String(e.sender.type)===`router`).map(e=>`group-message:${e.id}`)),i=new Map(n.labels);for(let e of r)i.set(e,l?`群组 AI Router`:`Group AI Router`);return{state:{...n.state,messages:n.state.messages.map(e=>r.has(e.id)?{...e,role:`assistant`}:e)},labels:i}},[e,u,f,l]),se=g(),ce=(0,J.useMemo)(()=>V([],{locale:c,t:e=>se(e)}),[c,se]),ue=(0,J.useMemo)(()=>i??(ce[`device.group.header`]??[]).filter(e=>!e.hidden),[i,ce]),de=(0,J.useMemo)(()=>s??(ce[`device.group.actions`]??[]).filter(e=>!e.hidden),[s,ce]),Y=f.filter(e=>e.enabled!==!1&&u?.room.botIds.includes(e.id)),Z=(0,J.useMemo)(()=>w.filter(e=>!!le(e)).length,[w]),Q=(0,J.useMemo)(()=>(u?.tasks??[]).filter(e=>e.status===`running`||e.status===`queued`),[u?.tasks]),fe=(0,J.useCallback)(async t=>{let n=t.conversationId||w.find(e=>e.botId===t.botId&&e.status!==`closed`)?.id;if(n)try{await Ye(`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(n)}/stop`,new AbortController().signal,{}),y(e=>e+1)}catch(e){m(e?.message||(l?`中止任务失败`:`Failed to stop task`))}},[e,w,l]);(0,J.useEffect)(()=>{qe({roomId:e,detail:u,devices:f,members:Y,conversations:w,attentionCount:Z,disabled:!t||h,conversationError:E})},[e,u,f,Y,w,Z,t,h,E]),(0,J.useEffect)(()=>()=>{qe(null)},[]);async function pe(n,r,i,a){if(!t||h||!u||ie.current)return!1;let o=i,s=w.find(e=>e.id===o);if(o&&(!s||s.status===`closed`||E||!Y.some(e=>e.id===s.botId)))return m(l?`所选对话不可用,请重新选择对话或新建任务。`:`Selected conversation is unavailable. Choose a conversation or New task.`),!1;if(s&&r.some(e=>e!==s.botId))return m(l?`继续对话只能发送给原 Bot,请移除其他目标。`:`Continue with the original Bot only. Remove other targets.`),!1;if(r.some(e=>!u.room.botIds.includes(e)))return!1;let c=a?.planOnly===!0,f=s?Y.filter(e=>e.id===s.botId):Y.filter(e=>r.includes(e.id)||!r.length&&!u.room.router?.enabled&&e.id===u.room.primaryBotId);if(c&&f.some(e=>!e.tools?.includes(`plan_update`)))return m(l?`所选 Bot 未授权 plan_update,请先在 Bot 工具白名单中启用。`:`Selected Bot is not authorized to use plan_update. Enable it in the Bot tool allowlist first.`),!1;let p=n.includes(`->`);q.current=z(q.current,JSON.stringify([e,o,c,p]),n,r,L);let g=new AbortController;re.current=g;let v=K.current;ie.current=!0;try{let t=`rooms/${encodeURIComponent(e)}`;return await Ye(o?`${t}/conversations/${encodeURIComponent(o)}/messages`:`${t}/messages`,g.signal,o?{text:n,kind:`message`,idempotencyKey:q.current.key,...c?{planOnly:!0}:{},...p?{pipeline:!0}:{}}:{text:n,targetBotIds:r,idempotencyKey:q.current.key,...c?{planOnly:!0}:{},...p?{pipeline:!0}:{}}),g.signal.aborted||K.current!==v?!1:(q.current=null,m(``),y(e=>e+1),!0)}catch(e){if(!g.signal.aborted&&K.current===v){if(o)return m(l?`继续对话失败,请重试或重新选择目标。`:`Could not continue the conversation. Retry or choose a target.`),!1;te(e)&&(d(null),_(!0)),m(G(e))}return!1}finally{re.current===g&&(ie.current=!1,re.current=null)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dg-head`,children:[(0,X.jsxs)(`div`,{className:`dg-head-info`,children:[(0,X.jsxs)(`div`,{className:`dg-head-brand`,children:[(0,X.jsx)(`span`,{className:`dg-brand-icon`,children:`⚡`}),(0,X.jsx)(`strong`,{className:`dg-head-title`,children:u?.room.name??(l?`联合开发群`:`Group Chat`)})]}),Y.length>0&&(0,X.jsxs)(`button`,{type:`button`,className:`dg-head-pill`,onClick:()=>N(`bots`),title:l?`点击查看协作 Bot 成员详情`:`Click to view collaborating Bots`,children:[(0,X.jsx)(`span`,{className:`dg-head-pill-dot`}),(0,X.jsxs)(`span`,{children:[Y.length,` `,l?`位协作 Bot`:`Bots`]})]})]}),(0,X.jsxs)(`div`,{className:`dg-head-nav`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`router`?`active`:``}`,onClick:()=>N(`router`),title:u?.room.router?.enabled?`${u.room.router.deviceId} · ${u.room.router.model} · ${u.room.router.thinkingLevel}`:l?`未启用 · 沿用原主 Bot 协作`:`Disabled · legacy primary Bot routing`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🧭`}),(0,X.jsxs)(`span`,{className:`dg-nav-text`,children:[`AI Router · `,u?.room.router?.enabled?l?`已启用`:`On`:l?`未启用`:`Off`]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`work-items`?`active`:``}`,onClick:()=>N(`work-items`),children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🗂`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`工单与运行`:`Work items & runs`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`blackboard`?`active`:``}`,onClick:()=>N(`blackboard`),title:l?`打开群组共享共识黑板`:`Open Group Blackboard`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📋`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`群黑板`:`Blackboard`}),u?.room.blackboard?.version?(0,X.jsxs)(`span`,{className:`dg-nav-badge`,children:[`v`,u.room.blackboard.version]}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`deliveries`?`active`:``} ${Z>0?`has-attention`:``}`,onClick:()=>N(`deliveries`),title:l?`打开交付与待办审查抽屉`:`Open Deliveries & Reviews`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📦`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`交付与待办`:`Deliveries`}),Z>0?(0,X.jsx)(`span`,{className:`dg-nav-badge attention`,children:Z}):w.length>0?(0,X.jsx)(`span`,{className:`dg-nav-badge`,children:w.length}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`transfers`?`active`:``}`,onClick:()=>N(`transfers`),title:l?`打开跨机大文件传输抽屉`:`Open Cross-Device File Transfers`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📁`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`文件传输`:`Transfers`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`canvas`?`active`:``}`,onClick:()=>N(`canvas`),title:l?`打开群画布工作流抽屉`:`Open Group Canvas`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🎨`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`群画布`:`Canvas`}),u?.room.canvasBinding&&(0,X.jsx)(`span`,{className:`dg-nav-dot active`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`presets`?`active`:``}`,onClick:()=>N(`presets`),title:l?`打开 Bot 预设与规则配置抽屉`:`Open Bot Presets`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🤖`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`Bot 预设`:`Presets`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`bots`?`active`:``}`,onClick:()=>N(`bots`),title:l?`查看成员运行状态与授权工具`:`View Bot Status`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`👥`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`成员状态`:`Bots`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`webhooks`?`active`:``}`,onClick:()=>N(`webhooks`),title:l?`配置入站与出站 Webhook`:`Configure Incoming and Outgoing Webhooks`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🔗`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`Webhook`:`Webhooks`}),u?.room.webhooks&&u.room.webhooks.filter(e=>e.enabled).length>0&&(0,X.jsx)(`span`,{className:`dg-nav-badge`,children:u.room.webhooks.filter(e=>e.enabled).length})]})]}),(0,X.jsxs)(`div`,{className:`dg-head-actions`,children:[ue.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,title:e.label,children:e.label},e.id)),n&&(0,X.jsxs)(`button`,{type:`button`,className:`btn dg-back-btn`,onClick:n,title:l?`返回普通对话`:`Back to single chat`,children:[`← `,l?`返回对话`:`Back to chat`]})]})]}),p&&(0,X.jsxs)(`div`,{className:`dg-error-banner`,role:`alert`,children:[p,h?l?`此群聊已删除或你已不在群中,请返回。`:`This group is unavailable or you are no longer a member. Return to chat.`:null]}),(0,X.jsx)(`div`,{className:`dg-tools-shelf collapsed`,"aria-hidden":`true`,style:{display:`none`},children:(0,X.jsxs)(`div`,{className:`dg-tools-shelf-content`,children:[(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(me,{roomId:e,conversations:w,bots:f,disabled:!t||h,error:E})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(Se,{roomId:e,bots:f,disabled:!t||h})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(De,{roomId:e,binding:u?.room.canvasBinding,onSaved:()=>y(e=>e+1)})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(ke,{bots:Y,onSaved:()=>y(e=>e+1)})})]})}),(Z>0||u?.tasks&&u.tasks.length>0)&&(0,X.jsxs)(`div`,{className:`dg-tasks-strip`,children:[Z>0&&(0,X.jsxs)(`button`,{type:`button`,className:`dg-task-chip dg-attention-chip ${k&&j===`deliveries`?`active`:``}`,onClick:()=>N(`deliveries`),title:l?`点击在协同抽屉中查看需要处理的交付与事项`:`View items needing attention in drawer`,children:[(0,X.jsx)(`span`,{className:`dg-attention-dot`}),(0,X.jsx)(`span`,{className:`dg-attention-text`,children:l?`${Z} 项待处理`:`${Z} need attention`})]}),(()=>{let e=u?.tasks??[],t=e.filter(e=>e.status===`running`||e.status===`waiting`||e.status===`queued`),n=e.slice(-4);if(t.length>0){let r=new Set(t.map(e=>e.id));for(let e of t)e.dependsOnTaskId&&r.add(e.dependsOnTaskId);let i=e.filter(e=>e.status===`completed`).slice(-2);for(let e of i)r.add(e.id);let a=e.filter(e=>r.has(e.id));n=a.length>0?a.slice(-6):e.slice(-6)}return n.map((e,t)=>{let{botPrefix:r,summary:i}=ne(e.text),a=t>0?n[t-1]:void 0,o=t>0&&(e.dependsOnTaskId===a?.id||a?.status===`completed`&&(e.status===`running`||e.status===`waiting`)||e.dependsOnTaskId!==void 0);return(0,X.jsxs)(`div`,{className:`dg-pipeline-step-wrapper`,children:[o&&(0,X.jsx)(`span`,{className:`dg-pipeline-arrow`,title:l?`流水线流转依赖`:`Pipeline flow dependency`,"aria-hidden":`true`,children:`→`}),(0,X.jsxs)(`div`,{className:`dg-task-chip ${e.status===`running`?`is-running`:``} ${e.status===`waiting`?`is-waiting`:``}`,children:[(0,X.jsx)(`span`,{className:`dg-task-status-dot status-${e.status}`,title:e.status===`waiting`?l?`等待前序任务`:`Waiting for upstream`:e.status}),e.status===`waiting`&&(0,X.jsx)(`span`,{className:`dg-task-waiting-badge`,children:l?`⏳ 等待中`:`⏳ Waiting`}),r&&(0,X.jsx)(`strong`,{className:`dg-task-bot-prefix`,children:r}),(0,X.jsx)(`span`,{className:`dg-task-title`,title:e.text,children:i.length>24?i.slice(0,24)+`...`:i}),(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn`,onClick:()=>U(e.id),children:l?`详情`:`Details`}),e.status===`running`&&(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn`,title:l?`飞行中实时注入转向纠偏`:`Inject in-flight steering`,onClick:()=>I(e),children:l?`转向`:`Steer`}),(e.status===`running`||e.status===`queued`||e.status===`waiting`)&&(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn dg-task-stop-action`,title:l?`中止此任务`:`Stop task`,onClick:()=>fe(e),children:l?`中止`:`Stop`})]})]},e.id)})})()]}),(0,X.jsx)(ve,{roomId:e,disabled:!t||h,refreshKey:b,connected:S}),(()=>{let t=u?.tasks.find(e=>e.id===R)??u?.tasks.find(e=>e.status===`running`)??u?.tasks.at(-1);return(0,X.jsx)(Ee,{roomId:e,activeTaskId:t?.id,taskSnapshotRevision:t?.botRevision,planState:t?.plan,uiSlotEntries:de,onStartPlanExecution:t?.status===`completed`?async t=>{await Ye(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/approve-plan`,new AbortController().signal,{}),y(e=>e+1)}:void 0})})(),(0,X.jsx)(B,{state:ae,liveOutputs:Xe,toolStatuses:Xe,messageLabels:oe,readOnly:!0}),R&&(0,X.jsx)(we,{roomId:e,taskId:R,onClose:ee}),F&&(0,X.jsx)(Ve,{task:F,botName:Y.find(e=>e.id===F.botId)?.name,deviceName:f.find(e=>e.id===F.botId)?.deviceName||F.deviceId,onClose:()=>I(null),onSubmit:async t=>{await Ye(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(F.id)}/steer`,new AbortController().signal,{text:t.trim()}),y(e=>e+1)}}),(0,X.jsx)(ze,{isOpen:k,activeTab:j,onClose:P,onSelectTab:M,roomId:e,detail:u,devices:f,members:Y,conversations:w,attentionCount:Z,disabled:!t||h,conversationError:E,onRefreshGroup:()=>y(e=>e+1),onRefreshConversations:()=>y(e=>e+1)}),(0,X.jsx)(W,{groupDevices:Y,groupPrimaryBotName:u?.room.router?.enabled?l?`群组 AI Router`:`Group AI Router`:Y.find(e=>e.id===u?.room.primaryBotId)?.name,groupConversations:w,groupConversationError:E,onGroupSend:pe,streaming:Q.length>0,onAbort:Q.length>0?()=>fe(Q[0]):void 0,messages:ae.messages,slashCommands:[],modelState:null,models:[],modelsLoading:!1,attachments:[],onRemoveAttachment:Ze,onAddImageFiles:Ze,onAddLocalFiles:Ze,onNotice:(e,t)=>m(t),onSent:Ze,onManageModels:Ze,providerKeys:{},quickPhrases:[],quickPhrasesEnabled:!1,groupReady:t&&!!u&&!h,sessionId:`device-group:${e}`,conversationId:`device-group:${e}`})]})}export{Qe as GroupConversation};
|
|
61
|
+
- Blocker: Missing device driver`;default:return d?`在此输入该分区的 Markdown 格式内容...`:`Enter Markdown content for this section...`}})(p),value:E,onChange:e=>k(e.target.value),disabled:A})]})}):(0,X.jsx)(`div`,{className:`dg-blackboard-content`,children:p===`all`?(0,X.jsxs)(X.Fragment,{children:[i?.title&&(0,X.jsx)(`h3`,{className:`dg-blackboard-title`,children:i.title}),i?.content?(0,X.jsx)(`div`,{className:`dg-blackboard-markdown`,children:(0,X.jsx)(te,{text:i.content})}):(0,X.jsxs)(`div`,{className:`dg-blackboard-empty`,children:[(0,X.jsx)(y,{style:{fontSize:32,opacity:.4,marginBottom:8}}),(0,X.jsx)(`p`,{children:d?`当前群组黑板为空。点击右上角“编辑共识”为所有协作 Bot 确立技术架构契约与长期记忆。`:`Blackboard is empty. Click 'Edit All' to set shared contracts and long-term memory.`})]})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`dg-bb-section-header`,children:(0,X.jsx)(`h4`,{className:`dg-bb-section-title`,children:V?d?V.titleZh:V.titleEn:B?.title||p})}),B?.content?(0,X.jsx)(`div`,{className:`dg-blackboard-markdown`,children:(0,X.jsx)(te,{text:B.content})}):(0,X.jsxs)(`div`,{className:`dg-blackboard-empty`,children:[(0,X.jsx)(y,{style:{fontSize:32,opacity:.4,marginBottom:8}}),(0,X.jsx)(`p`,{children:d?`该分区当前尚无记录内容。点击右上角“编辑此分区”快速添加共识与规则。`:`No content in this section yet. Click 'Edit Section' to add consensus and specifications.`})]})]})})]})}var Fe=[{id:`message`,zh:`新群聊消息`,en:`New message`},{id:`task_completed`,zh:`Bot 任务成功完成`,en:`Task completed`},{id:`task_failed`,zh:`Bot 任务执行失败`,en:`Task failed`},{id:`delivery`,zh:`Bot 代码交付提交`,en:`Code delivery`}];function Ie({roomId:e,disabled:n=!1}){let{locale:i}=a(),u=D(i),[d,f]=(0,J.useState)([]),[p,h]=(0,J.useState)(!0),[g,y]=(0,J.useState)(``),[b,S]=(0,J.useState)(!1),[C,w]=(0,J.useState)(null),[T,E]=(0,J.useState)(``),[O,N]=(0,J.useState)(``),[P,F]=(0,J.useState)(!1),[I,L]=(0,J.useState)(``),[R,z]=(0,J.useState)(!1),[B,V]=(0,J.useState)(`hub`),[H,U]=(0,J.useState)(null),[ee,te]=(0,J.useState)(null),[ne,W]=(0,J.useState)(null),G=(0,J.useRef)(null),K=async()=>{G.current&&G.current.abort();let t=new AbortController;G.current=t;try{y(``);let[n,i,a]=await Promise.all([fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks`)),{signal:t.signal}),fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}`)),{signal:t.signal}).catch(()=>null),fetch(r(o(`/api/device-center/status`)),{signal:t.signal}).catch(()=>null)]);if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`HTTP ${n.status}`)}let s=await n.json();if(f(s.webhooks||[]),i&&i.ok){let e=(await i.json()).room?.hubRelayBaseUrl||``;N(e),L(e)}if(a&&a.ok){let e=await a.json();e.hubUrl&&E(e.hubUrl)}}catch(e){t.signal.aborted||y(e?.message||(u?`加载 Webhooks 失败`:`Failed to load webhooks`))}finally{t.signal.aborted||h(!1)}};(0,J.useEffect)(()=>(h(!0),K(),()=>{G.current&&G.current.abort()}),[e]);let re=O||T||window.location.origin,q=async()=>{z(!0),y(``);try{let t=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/hub-relay`)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({hubRelayBaseUrl:I.trim()||null})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error||`Failed to update Hub relay base URL`)}N(I.trim()),F(!1)}catch(e){y(e?.message||`Failed to save Hub relay URL`)}finally{z(!1)}},ie=(e,t)=>{navigator.clipboard.writeText(e),U(t),setTimeout(()=>U(null),2e3)},ae=async t=>{try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}`)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({enabled:!t.enabled})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Update failed`)}await K()}catch(e){y(e?.message||`Failed to update webhook`)}},oe=async t=>{if(window.confirm(u?`确定要删除该 Webhook 吗?`:`Are you sure you want to delete this webhook?`))try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}/delete`)),{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Delete failed`)}await K()}catch(e){y(e?.message||`Failed to delete webhook`)}},se=async t=>{if(window.confirm(u?`重新生成 Token 将使旧 Token 立即失效,依赖此 URL 的外部服务需要同步更新。确定重新生成?`:`Regenerating the token will invalidate the old one immediately. Continue?`))try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t)}/regenerate-token`)),{method:`POST`});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error||`Regenerate failed`)}await K()}catch(e){y(e?.message||`Failed to regenerate token`)}},ce=async t=>{te(t.id),W(null);try{let n=await fetch(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}/test`)),{method:`POST`}),i=await n.json().catch(()=>({}));if(n.ok&&i.success){let e=t.relayViaHub===!1?``:u?` [Hub中转]`:` [via Hub]`;W({id:t.id,success:!0,message:u?`推送成功${e} (HTTP ${i.status??200})`:`Delivered successfully${e} (HTTP ${i.status??200})`})}else W({id:t.id,success:!1,message:i.error||(u?`推送测试失败`:`Test failed`)})}catch(e){W({id:t.id,success:!1,message:e?.message||`Network request failed`})}finally{te(null)}},le=d.filter(e=>e.type===`incoming`),ue=d.filter(e=>e.type===`outgoing`);return(0,X.jsxs)(`div`,{className:`group-webhooks-container`,children:[(0,X.jsxs)(`div`,{className:`group-webhooks-header`,children:[(0,X.jsx)(`div`,{className:`group-webhooks-desc`,children:(0,X.jsx)(`p`,{children:u?`群组 Webhook 支持双向通信与可选 Hub 中转:入站可使用公网 Hub 中转地址接收外部事件唤醒 Bot;出站通知可选由 Hub 服务端中转代发。`:`Two-way Webhooks with optional Hub relay: incoming uses Hub public relay endpoints, outgoing supports relaying via Hub.`})}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary group-webhooks-add-btn`,disabled:n,onClick:()=>{w(null),S(!0)},children:[(0,X.jsx)(c,{}),(0,X.jsx)(`span`,{children:u?`新建 Webhook`:`Add Webhook`})]})]}),g&&(0,X.jsxs)(`div`,{className:`group-webhooks-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:g})]}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-bar`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-relay-info`,children:[(0,X.jsx)(j,{className:`icon-hub`}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-text`,children:[(0,X.jsx)(`strong`,{children:u?`Hub 中转基准地址:`:`Hub Relay Base URL:`}),(0,X.jsx)(`code`,{children:re}),O&&(0,X.jsx)(`span`,{className:`badge-custom`,children:u?`自定义`:`Custom`})]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,onClick:()=>F(!P),title:u?`配置自定义 Hub 中转基准域名`:`Configure Hub relay base URL`,children:[(0,X.jsx)(A,{}),(0,X.jsx)(`span`,{children:u?`设置中转域名`:`Relay URL`})]})]}),P&&(0,X.jsx)(`div`,{className:`group-webhook-relay-config-box`,children:(0,X.jsxs)(`div`,{className:`group-webhook-relay-config-fields`,children:[(0,X.jsx)(`label`,{children:u?`若 Hub 位于公网反向代理或具有独立域名,请输入对外公开的完整基准地址(如 https://hub.example.com):`:`Specify the public Hub URL (e.g. https://hub.example.com) if behind a reverse proxy:`}),(0,X.jsxs)(`div`,{className:`group-webhook-relay-input-row`,children:[(0,X.jsx)(`input`,{type:`url`,className:`input`,placeholder:`https://hub.example.com`,value:I,onChange:e=>L(e.target.value)}),(0,X.jsx)(`button`,{type:`button`,className:`btn primary sm`,disabled:R,onClick:q,children:R?u?`保存中…`:`Saving...`:u?`保存中转地址`:`Save`}),O&&(0,X.jsx)(`button`,{type:`button`,className:`btn secondary sm`,disabled:R,onClick:()=>{L(``),q()},children:u?`重置`:`Reset`})]})]})}),p?(0,X.jsx)(`div`,{className:`group-webhooks-loading`,children:u?`正在加载 Webhook 列表…`:`Loading webhooks...`}):d.length===0?(0,X.jsxs)(`div`,{className:`group-webhooks-empty`,children:[(0,X.jsx)(`div`,{className:`group-webhooks-empty-icon`,children:`🔗`}),(0,X.jsx)(`h4`,{children:u?`暂未配置群组 Webhook`:`No Webhooks Configured`}),(0,X.jsx)(`p`,{children:u?`点击上方「新建 Webhook」创建入站或出站自动化集成。`:`Click 'Add Webhook' above to create incoming or outgoing automations.`})]}):(0,X.jsxs)(`div`,{className:`group-webhooks-list`,children:[le.length>0&&(0,X.jsxs)(`div`,{className:`group-webhooks-section`,children:[(0,X.jsxs)(`div`,{className:`group-webhooks-section-header`,children:[(0,X.jsxs)(`h4`,{className:`group-webhooks-section-title`,children:[(0,X.jsx)(M,{className:`icon-incoming`}),(0,X.jsx)(`span`,{children:u?`入站 Webhook (Incoming)`:`Incoming Webhooks`}),(0,X.jsx)(`span`,{className:`badge`,children:le.length})]}),(0,X.jsxs)(`div`,{className:`group-webhook-mode-toggle`,title:u?`选择生成中转还是直连地址`:`Select address mode`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`mode-btn ${B===`hub`?`active`:``}`,onClick:()=>V(`hub`),children:[`🌐 `,u?`Hub 中转地址`:`Hub Relay`]}),(0,X.jsxs)(`button`,{type:`button`,className:`mode-btn ${B===`direct`?`active`:``}`,onClick:()=>V(`direct`),children:[`💻 `,u?`本地直连地址`:`Direct`]})]})]}),(0,X.jsx)(`div`,{className:`group-webhooks-cards`,children:le.map(r=>{let i=`${B===`hub`?re:window.location.origin}/api/rooms/${e}/webhooks/incoming/${r.id}?token=${r.token}`,a=`curl -X POST "${i}" -H "Content-Type: application/json" -d '{"text":"Hello from Webhook","senderName":"${r.name}"}'`;return(0,X.jsxs)(`div`,{className:`group-webhook-card ${r.enabled?`enabled`:`disabled`}`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-card-header`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-name-box`,children:[(0,X.jsx)(`strong`,{className:`group-webhook-name`,children:r.name}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${r.enabled?`badge-active`:`badge-inactive`}`,children:r.enabled?u?`已启用`:`Active`:u?`已暂停`:`Disabled`}),(0,X.jsx)(`span`,{className:`group-webhook-badge badge-relay`,children:B===`hub`?u?`🌐 Hub中转`:`🌐 Hub Relay`:u?`💻 本机直连`:`💻 Direct`}),r.allowBotTrigger!==!1&&(0,X.jsx)(`span`,{className:`group-webhook-badge badge-info`,title:u?`收到外部消息时自动触发群主管或被 @ 的 Bot`:`Triggers Bot execution`,children:u?`可唤醒 Bot`:`Triggers Bot`})]}),(0,X.jsxs)(`div`,{className:`group-webhook-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`编辑`:`Edit`,disabled:n,onClick:()=>{w(r),S(!0)},children:(0,X.jsx)(v,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle danger`,title:u?`删除`:`Delete`,disabled:n,onClick:()=>oe(r.id),children:(0,X.jsx)(k,{})}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":r.enabled,className:`set-switch ${r.enabled?`on`:``}`,disabled:n,onClick:()=>ae(r),title:u?`启用/禁用切换`:`Toggle status`,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsxs)(`label`,{children:[u?`Webhook 入站地址:`:`Webhook URL:`,(0,X.jsxs)(`span`,{className:`mode-indicator`,children:[`(`,B===`hub`?u?`外部经 Hub 中转打入`:`Forwarded via Hub`:u?`本地端口直通`:`Direct access`,`)`]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-url-row`,children:[(0,X.jsx)(`code`,{className:`group-webhook-code`,children:i}),(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,title:u?`复制 URL`:`Copy URL`,onClick:()=>ie(i,`url-${r.id}`),children:[H===`url-${r.id}`?(0,X.jsx)(t,{}):(0,X.jsx)(s,{}),(0,X.jsx)(`span`,{children:H===`url-${r.id}`?u?`已复制`:`Copied`:u?`复制`:`Copy`})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn secondary sm`,title:u?`重新生成安全凭证 Token`:`Regenerate Token`,disabled:n,onClick:()=>se(r.id),children:(0,X.jsx)(_,{})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`调用示例 (cURL):`:`cURL Example:`}),(0,X.jsxs)(`div`,{className:`group-webhook-curl-box`,children:[(0,X.jsx)(`code`,{children:a}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`复制 cURL`:`Copy cURL`,onClick:()=>ie(a,`curl-${r.id}`),children:H===`curl-${r.id}`?(0,X.jsx)(t,{}):(0,X.jsx)(s,{})})]})]})]},r.id)})})]}),ue.length>0&&(0,X.jsxs)(`div`,{className:`group-webhooks-section`,children:[(0,X.jsxs)(`h4`,{className:`group-webhooks-section-title`,children:[(0,X.jsx)(m,{className:`icon-outgoing`}),(0,X.jsx)(`span`,{children:u?`出站 Webhook (Outgoing)`:`Outgoing Webhooks`}),(0,X.jsx)(`span`,{className:`badge`,children:ue.length})]}),(0,X.jsx)(`div`,{className:`group-webhooks-cards`,children:ue.map(e=>{let r=ee===e.id,i=ne?.id===e.id?ne:null,a=e.relayViaHub!==!1;return(0,X.jsxs)(`div`,{className:`group-webhook-card ${e.enabled?`enabled`:`disabled`}`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-card-header`,children:[(0,X.jsxs)(`div`,{className:`group-webhook-name-box`,children:[(0,X.jsx)(`strong`,{className:`group-webhook-name`,children:e.name}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${e.enabled?`badge-active`:`badge-inactive`}`,children:e.enabled?u?`已启用`:`Active`:u?`已暂停`:`Disabled`}),(0,X.jsx)(`span`,{className:`group-webhook-badge ${a?`badge-relay`:`badge-direct`}`,title:a?u?`由 Hub 服务器统一代理出网外发`:`Relayed via Hub server`:u?`由本地设备节点直连外发`:`Direct connection from device`,children:a?u?`🌐 Hub中转代发`:`🌐 Hub Relay`:u?`💻 本地直连外发`:`💻 Direct Outbound`}),e.secret?(0,X.jsx)(`span`,{className:`group-webhook-badge badge-secret`,title:u?`已配置 HMAC-SHA256 签名校验密钥`:`HMAC secret configured`,children:u?`带签名`:`Signed`}):null]}),(0,X.jsxs)(`div`,{className:`group-webhook-actions`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`btn secondary sm`,disabled:n||r,onClick:()=>ce(e),title:u?`向目标地址发送一条测试 Ping`:`Send test ping`,children:[(0,X.jsx)(l,{}),(0,X.jsx)(`span`,{children:r?u?`测试中…`:`Testing...`:u?`测试`:`Test`})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle`,title:u?`编辑`:`Edit`,disabled:n,onClick:()=>{w(e),S(!0)},children:(0,X.jsx)(v,{})}),(0,X.jsx)(`button`,{type:`button`,className:`btn-icon-subtle danger`,title:u?`删除`:`Delete`,disabled:n,onClick:()=>oe(e.id),children:(0,X.jsx)(k,{})}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":e.enabled,className:`set-switch ${e.enabled?`on`:``}`,disabled:n,onClick:()=>ae(e),title:u?`启用/禁用切换`:`Toggle status`,children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`目标推送 URL:`:`Target URL:`}),(0,X.jsx)(`code`,{className:`group-webhook-code`,children:e.url})]}),(0,X.jsxs)(`div`,{className:`group-webhook-field`,children:[(0,X.jsx)(`label`,{children:u?`订阅事件:`:`Subscribed Events:`}),(0,X.jsx)(`div`,{className:`group-webhook-event-chips`,children:(e.events||[`message`,`task_completed`,`task_failed`,`delivery`]).map(e=>{let t=Fe.find(t=>t.id===e);return(0,X.jsx)(`span`,{className:`group-webhook-event-chip`,children:t?u?t.zh:t.en:e},e)})})]}),i&&(0,X.jsxs)(`div`,{className:`group-webhook-test-result ${i.success?`success`:`failed`}`,children:[i.success?(0,X.jsx)(t,{}):(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:i.message})]})]},e.id)})})]})]}),b&&(0,X.jsx)(Le,{roomId:e,webhook:C,onClose:()=>{S(!1),w(null)},onSaved:async()=>{S(!1),w(null),await K()}})]})}function Le({roomId:e,webhook:t,onClose:n,onSaved:i}){let{locale:s}=a(),c=D(s),l=!!t,[u,d]=(0,J.useState)(t?.name||``),[f,p]=(0,J.useState)(t?.type||`incoming`),[m,h]=(0,J.useState)(!t||t.enabled),[g,_]=(0,J.useState)(!t||t.allowBotTrigger!==!1),[v,y]=(0,J.useState)(!t||t.relayViaHub!==!1),[b,S]=(0,J.useState)(t?.url||``),[C,w]=(0,J.useState)(t?.secret||``),[T,E]=(0,J.useState)(t?.events||[`message`,`task_completed`,`task_failed`,`delivery`]),[O,k]=(0,J.useState)(!1),[A,j]=(0,J.useState)(``),M=async n=>{if(n.preventDefault(),!u.trim()){j(c?`请输入 Webhook 名称`:`Name is required`);return}if(f===`outgoing`&&(!b.trim()||!/^https?:\/\/.+/i.test(b.trim()))){j(c?`请输入有效的 http:// 或 https:// 目标地址`:`Valid HTTP/HTTPS URL is required`);return}k(!0),j(``);try{let n={name:u.trim(),enabled:m};l||(n.type=f),f===`incoming`?n.allowBotTrigger=g:(n.url=b.trim(),n.secret=C.trim()||void 0,n.events=T,n.relayViaHub=v);let a=l?`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks/${encodeURIComponent(t.id)}`:`/api/device-center/rooms/${encodeURIComponent(e)}/webhooks`,s=await fetch(r(o(a)),{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!s.ok){let e=await s.json().catch(()=>({}));throw Error(e.error||`Save failed`)}i()}catch(e){j(e?.message||`Failed to save webhook`)}finally{k(!1)}},N=e=>{if(T.includes(e)){if(T.length===1)return;E(T.filter(t=>t!==e))}else E([...T,e])};return(0,X.jsx)(`div`,{className:`modal-backdrop`,onClick:n,children:(0,X.jsxs)(`div`,{className:`group-webhook-modal-dialog`,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-modal":`true`,children:[(0,X.jsxs)(`div`,{className:`gwm-header`,children:[(0,X.jsxs)(`div`,{className:`gwm-title-box`,children:[(0,X.jsxs)(`h3`,{children:[(0,X.jsx)(`span`,{className:`gwm-title-icon`,children:`🔗`}),` `,l?c?`编辑 Webhook`:`Edit Webhook`:c?`新建 Webhook`:`New Webhook`]}),(0,X.jsx)(`p`,{className:`gwm-subtitle`,children:c?`配置入站自动化触发或出站事件广播通知`:`Configure incoming automations or outgoing event notifications`})]}),(0,X.jsx)(`button`,{type:`button`,className:`gwm-close-btn`,onClick:n,"aria-label":c?`关闭`:`Close`,title:c?`关闭`:`Close`,children:`✕`})]}),(0,X.jsxs)(`form`,{onSubmit:M,children:[(0,X.jsxs)(`div`,{className:`gwm-body`,children:[A&&(0,X.jsxs)(`div`,{className:`group-webhooks-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{}),(0,X.jsx)(`span`,{children:A})]}),!l&&(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{className:`gwm-label`,children:c?`集成类型`:`Integration Type`}),(0,X.jsxs)(`div`,{className:`gwm-type-cards`,children:[(0,X.jsxs)(`div`,{className:`gwm-type-card ${f===`incoming`?`selected`:``}`,onClick:()=>p(`incoming`),role:`button`,tabIndex:0,children:[(0,X.jsx)(`span`,{className:`gwm-type-check`,children:`✓`}),(0,X.jsxs)(`div`,{className:`gwm-type-card-head`,children:[(0,X.jsx)(`span`,{className:`gwm-type-icon incoming`,children:`📥`}),(0,X.jsx)(`span`,{className:`gwm-type-name`,children:c?`入站 Webhook`:`Incoming Webhook`})]}),(0,X.jsx)(`p`,{className:`gwm-type-desc`,children:c?`外部系统推送消息进群,可自动指派或唤醒群内 Bot 执行任务`:`External services push messages to this group & trigger Bots`})]}),(0,X.jsxs)(`div`,{className:`gwm-type-card ${f===`outgoing`?`selected`:``}`,onClick:()=>p(`outgoing`),role:`button`,tabIndex:0,children:[(0,X.jsx)(`span`,{className:`gwm-type-check`,children:`✓`}),(0,X.jsxs)(`div`,{className:`gwm-type-card-head`,children:[(0,X.jsx)(`span`,{className:`gwm-type-icon outgoing`,children:`📤`}),(0,X.jsx)(`span`,{className:`gwm-type-name`,children:c?`出站 Webhook`:`Outgoing Webhook`})]}),(0,X.jsx)(`p`,{className:`gwm-type-desc`,children:c?`将新消息、任务完成、失败或交付等事件实时推送至外部服务`:`Forward messages, task completions, and deliveries to external endpoints`})]})]})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-name`,className:`gwm-label`,children:c?`Webhook 名称`:`Webhook Name`}),(0,X.jsx)(`input`,{id:`webhook-name`,type:`text`,className:`gwm-input`,placeholder:c?`例如:GitHub Actions CI、监控告警、飞书群通知`:`e.g. GitHub Actions CI, Sentry Alerts`,value:u,maxLength:80,onChange:e=>d(e.target.value),autoFocus:!0})]}),f===`incoming`?(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>_(!g),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`收到外部推送时唤醒 Bot 执行任务`:`Allow incoming messages to trigger Bots`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`检测到消息包含 @Bot 或群组设有群主管时,自动生成任务派发`:`Triggers coordinator or mentioned Bots automatically`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":g,className:`set-switch ${g?`on`:``}`,onClick:e=>{e.stopPropagation(),_(!g)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-url`,className:`gwm-label`,children:c?`目标推送 URL`:`Target Endpoint URL`}),(0,X.jsx)(`input`,{id:`webhook-url`,type:`url`,className:`gwm-input`,placeholder:`https://example.com/webhook/endpoint`,value:b,onChange:e=>S(e.target.value)}),(0,X.jsx)(`span`,{className:`gwm-field-hint`,children:c?`事件触发时,系统将以 HTTP POST 发送 JSON 格式载荷至此地址。`:`Delivered as HTTP POST with JSON content.`})]}),(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>y(!v),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`通过 Hub 服务端中转代发 (Relay via Hub)`:`Relay via Hub Server`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`由 Hub 服务器统一作为代理外发通知(固定出口 IP);若目标是局域网私有地址请关闭`:`Dispatched centrally by Hub. Uncheck if target is internal LAN address.`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":v,className:`set-switch ${v?`on`:``}`,onClick:e=>{e.stopPropagation(),y(!v)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{htmlFor:`webhook-secret`,className:`gwm-label`,children:c?`签名密钥 Secret(可选)`:`HMAC Secret (Optional)`}),(0,X.jsx)(`input`,{id:`webhook-secret`,type:`text`,className:`gwm-input`,placeholder:c?`可选密钥,用于生成 X-Pi-Signature 请求头防篡改校验`:`Optional secret used for X-Pi-Signature header`,value:C,maxLength:256,onChange:e=>w(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`gwm-form-group`,children:[(0,X.jsx)(`label`,{className:`gwm-label`,children:c?`订阅事件`:`Subscribed Events`}),(0,X.jsx)(`div`,{className:`gwm-events-grid`,children:Fe.map(e=>(0,X.jsxs)(`div`,{className:`gwm-event-chip ${T.includes(e.id)?`active`:``}`,onClick:()=>N(e.id),children:[(0,X.jsx)(`span`,{className:`gwm-chip-box`,children:T.includes(e.id)?`✓`:``}),(0,X.jsx)(`span`,{children:c?e.zh:e.en})]},e.id))})]})]}),(0,X.jsxs)(`div`,{className:`gwm-switch-row`,onClick:()=>h(!m),children:[(0,X.jsxs)(`div`,{className:`gwm-switch-text`,children:[(0,X.jsx)(`span`,{className:`gwm-switch-title`,children:c?`立即启用该 Webhook`:`Enable this Webhook`}),(0,X.jsx)(`span`,{className:`gwm-switch-desc`,children:c?`创建完成后立即生效并接受/分发事件`:`Active immediately upon save`})]}),(0,X.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":m,className:`set-switch ${m?`on`:``}`,onClick:e=>{e.stopPropagation(),h(!m)},children:(0,X.jsx)(`span`,{className:`set-switch-knob`})})]})]}),(0,X.jsxs)(`div`,{className:`gwm-footer`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,onClick:n,disabled:O,children:c?`取消`:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,className:`btn primary`,disabled:O,children:O?c?`保存中…`:`Saving...`:l?c?`保存修改`:`Save Changes`:c?`创建 Webhook`:`Create Webhook`})]})]})]})})}var Re=()=>{},ze=(0,J.memo)(function({isOpen:e,activeTab:t,onClose:n,roomId:r,detail:i,devices:o,members:s,conversations:c,attentionCount:l,disabled:u,conversationError:d,onRefreshGroup:f,onRefreshConversations:p}){let{locale:m}=a(),h=D(m);if((0,J.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,n]),!e)return null;let g={router:{icon:`🧭`,title:h?`群组 AI Router`:`Group AI Router`},"work-items":{icon:`🗂`,title:h?`群组工单与 Router 运行`:`Work Items & Router Runs`},blackboard:{icon:`📋`,title:h?`群组共享共识黑板`:`Group Shared Blackboard`,badge:i?.room.blackboard?.version},deliveries:{icon:`📦`,title:h?`交付与待办事项`:`Deliveries & Attention`,badge:l>0?l:c.length>0?c.length:void 0},transfers:{icon:`📁`,title:h?`跨机大文件传输与断点续传`:`Cross-Device File Transfers`},canvas:{icon:`🎨`,title:h?`群画布工作流`:`Group Canvas Workflow`},presets:{icon:`🤖`,title:h?`Bot 预设与规则配置`:`Bot Presets & Settings`},bots:{icon:`👥`,title:h?`群协作 Bot 成员清单`:`Collaborating Bots`,badge:s.length},webhooks:{icon:`🔗`,title:h?`群组 Webhook 集成`:`Group Webhooks`,badge:i?.room.webhooks?.filter(e=>e.enabled).length}}[t]||{icon:`📦`,title:h?`群协同`:`Collaboration`};return(0,X.jsxs)(`div`,{className:`group-drawer-overlay`,role:`dialog`,"aria-modal":`true`,"aria-label":g.title,children:[(0,X.jsx)(`div`,{className:`group-drawer-backdrop`,onClick:n,"aria-hidden":!0}),(0,X.jsxs)(`aside`,{className:`group-drawer-panel`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`group-drawer-header`,children:[(0,X.jsxs)(`div`,{className:`group-drawer-title-box`,children:[(0,X.jsx)(`span`,{className:`group-drawer-title-icon`,children:g.icon}),(0,X.jsx)(`h3`,{className:`group-drawer-title`,children:g.title}),g.badge!==void 0&&g.badge>0&&(0,X.jsx)(`span`,{className:`group-drawer-badge ${t===`deliveries`&&l>0?`attention`:``}`,children:g.badge})]}),(0,X.jsx)(`button`,{type:`button`,className:`btn group-drawer-close-btn`,onClick:n,title:h?`关闭抽屉 (Esc)`:`Close Drawer (Esc)`,"aria-label":h?`关闭`:`Close`,children:(0,X.jsx)(w,{})})]}),(0,X.jsxs)(`div`,{className:`group-drawer-body`,children:[t===`router`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(G,{roomId:r,router:i?.room.router,disabled:u,onSaved:f??Re},r)}),t===`work-items`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(K,{roomId:r,tasks:i?.tasks,disabled:u,onChanged:f},r)}),t===`blackboard`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Pe,{roomId:r,blackboard:i?.room.blackboard,disabled:u,onSaved:f??Re})}),t===`deliveries`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(me,{roomId:r,conversations:c,bots:o,disabled:u,error:d,onRefresh:p})}),t===`transfers`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Se,{roomId:r,bots:o,disabled:u})}),t===`canvas`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(De,{roomId:r,binding:i?.room.canvasBinding,onSaved:f??Re})}),t===`presets`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(ke,{bots:s,onSaved:f??Re})}),t===`webhooks`&&(0,X.jsx)(`div`,{className:`group-drawer-pane`,children:(0,X.jsx)(Ie,{roomId:r,disabled:u})}),t===`bots`&&(0,X.jsxs)(`div`,{className:`group-drawer-pane group-members-overview`,children:[(0,X.jsxs)(`div`,{className:`grp-section-title`,children:[(0,X.jsx)(`span`,{children:h?`群协作 Bot 成员清单`:`Collaborating Bots`}),(0,X.jsxs)(`span`,{className:`grp-count`,children:[`(`,s.length,`)`]})]}),(0,X.jsx)(`div`,{className:`grp-bot-list`,children:s.map(e=>(0,X.jsxs)(`div`,{className:`grp-bot-card`,children:[(0,X.jsxs)(`div`,{className:`grp-bot-card-top`,children:[(0,X.jsxs)(`div`,{className:`grp-bot-title`,children:[(0,X.jsx)(`span`,{className:`grp-bot-indicator ${e.online===!1?`offline`:`online`}`}),(0,X.jsx)(`strong`,{children:e.name}),!i?.room.router?.enabled&&e.id===i?.room.primaryBotId&&(0,X.jsx)(`span`,{className:`grp-primary-badge`,children:h?`主协调`:`Primary`})]}),(0,X.jsx)(`span`,{className:`grp-bot-status-text`,children:e.online===!1?h?`离线`:`Offline`:h?`在线就绪`:`Online Ready`})]}),(0,X.jsxs)(`div`,{className:`grp-bot-info`,children:[e.deviceName&&(0,X.jsxs)(`div`,{className:`grp-bot-device`,children:[(0,X.jsxs)(`span`,{children:[`🖥 `,h?`设备: `:`Device: `]}),(0,X.jsx)(`code`,{children:e.deviceName})]}),(0,X.jsxs)(`div`,{className:`grp-bot-id`,children:[(0,X.jsx)(`span`,{children:`ID: `}),(0,X.jsx)(`code`,{title:e.id,children:e.id})]})]}),e.tools&&e.tools.length>0&&(0,X.jsxs)(`div`,{className:`grp-bot-tools`,children:[(0,X.jsx)(`span`,{className:`grp-tools-label`,children:h?`授权工具: `:`Tools: `}),(0,X.jsx)(`div`,{className:`grp-tools-chips`,children:e.tools.map(e=>(0,X.jsx)(`span`,{className:`grp-tool-chip`,children:e},e))})]})]},e.id))})]})]})]})]})}),Be=[{id:`summarize-finish`,labelZh:`直接汇总当前阶段产物并结束`,labelEn:`Summarize & Finish`,textZh:`直接汇总当前阶段产物并结束,保留关键交付物与验证结论。`,textEn:`Directly summarize current phase deliverables and finish, retaining key evidence and conclusions.`},{id:`check-types`,labelZh:`优先检查并补充类型声明`,labelEn:`Prioritize Types`,textZh:`优先检查并补充缺失的类型声明,确保 strict typecheck 零错误。`,textEn:`Prioritize checking and adding type declarations to ensure zero typecheck errors.`},{id:`self-test`,labelZh:`先进行自测并展示通过证据`,labelEn:`Self-test & Show Evidence`,textZh:`先进行自测并展示通过证据,包括具体的测试用例与终端运行输出。`,textEn:`Run self-tests first and present verification evidence including test cases and terminal output.`},{id:`concise-report`,labelZh:`精简输出与风险`,labelEn:`Concise Output & Risks`,textZh:`精简后续输出,跳过冗余细节,仅汇报核心变更、未决风险与阻碍项。`,textEn:`Keep subsequent output concise; report only core changes, unresolved risks, and blockers.`}];function Ve({task:e,botName:n,deviceName:r,onClose:i,onSubmit:o}){let{locale:s}=a(),c=D(s),[l,f]=(0,J.useState)(``),[p,m]=(0,J.useState)(!1),[h,g]=(0,J.useState)(null),v=(0,J.useRef)(null);(0,J.useEffect)(()=>{v.current?.focus()},[]);let y=(0,J.useCallback)(e=>{let t=c?e.textZh:e.textEn;f(e=>e.trim()?`${e.trim()}\n${t}`:t),v.current?.focus()},[c]),b=(0,J.useCallback)(async()=>{let e=l.trim();if(!e){g(c?`请输入转向纠偏指令`:`Please enter steering instruction`);return}m(!0),g(null);try{await o(e),i()}catch(e){g(e?.message||(c?`注入转向指令失败`:`Failed to inject steering instruction`))}finally{m(!1)}},[l,o,i,c]),S=(0,J.useCallback)(e=>{(e.ctrlKey||e.metaKey)&&e.key===`Enter`&&(e.preventDefault(),b())},[b]),w=R(e.text),T=n||e.botId,E=r||e.deviceId;return(0,X.jsx)(B,{open:!0,onClose:i,title:c?`任务飞行中实时转向 (In-flight Steering)`:`In-flight Task Steering`,icon:(0,X.jsx)(d,{className:`dg-steer-icon`}),className:`dg-steer-modal`,children:(0,X.jsxs)(`div`,{className:`dg-steer-body`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-target-card`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-target-header`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-bot-badge`,children:[(0,X.jsx)(u,{style:{marginRight:4}}),(0,X.jsxs)(`strong`,{children:[`@`,T]})]}),E&&(0,X.jsx)(`span`,{className:`dg-steer-device-name`,title:c?`目标设备`:`Target Device`,children:E}),(0,X.jsxs)(`span`,{className:`dg-steer-task-id`,title:e.id,children:[`#`,e.id.slice(0,8)]})]}),(0,X.jsxs)(`div`,{className:`dg-steer-target-text`,title:w,children:[(0,X.jsx)(`span`,{className:`dg-steer-text-label`,children:c?`当前目标:`:`Current Goal: `}),w]}),e.progress?.phase&&(0,X.jsxs)(`div`,{className:`dg-steer-progress-tag`,children:[(0,X.jsx)(`span`,{className:`dg-steer-progress-dot`}),(0,X.jsxs)(`span`,{children:[c?`阶段`:`Phase`,`: `,(0,X.jsx)(`code`,{children:e.progress.phase}),e.progress.toolName&&` · Tool: ${e.progress.toolName}`]})]})]}),(0,X.jsxs)(`div`,{className:`dg-steer-presets-section`,children:[(0,X.jsxs)(`div`,{className:`dg-steer-presets-header`,children:[(0,X.jsx)(C,{className:`dg-steer-zap-icon`}),(0,X.jsx)(`span`,{children:c?`常用纠偏预设(点击快速填入)`:`Quick Steering Presets`})]}),(0,X.jsx)(`div`,{className:`dg-steer-preset-chips`,children:Be.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`dg-steer-preset-chip`,onClick:()=>y(e),disabled:p,title:c?e.textZh:e.textEn,children:c?e.labelZh:e.labelEn},e.id))})]}),(0,X.jsxs)(`div`,{className:`dg-steer-input-section`,children:[(0,X.jsx)(`label`,{className:`dg-field-label`,children:c?`转向指令 (Ctrl+Enter 提交)`:`Steering Instruction (Ctrl+Enter to submit)`}),(0,X.jsx)(`textarea`,{ref:v,className:`dg-steer-textarea`,rows:4,placeholder:c?`例如:当前步骤已通过,请直接进行单元测试并汇报覆盖率;或者跳过重构,保持既有接口契约。`:`e.g. Current phase looks good, please jump to unit tests; or skip refactoring and adhere to contracts.`,value:l,onChange:e=>f(e.target.value),onKeyDown:S,disabled:p})]}),h&&(0,X.jsxs)(`div`,{className:`dg-error-banner`,role:`alert`,children:[(0,X.jsx)(x,{style:{marginRight:6,flexShrink:0}}),(0,X.jsx)(`span`,{children:h})]}),(0,X.jsxs)(`div`,{className:`dg-steer-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,onClick:i,disabled:p,children:c?`取消`:`Cancel`}),(0,X.jsxs)(`button`,{type:`button`,className:`btn primary`,onClick:b,disabled:p||!l.trim(),children:[p?(0,X.jsx)(_,{className:`spin`,style:{marginRight:6}}):(0,X.jsx)(t,{style:{marginRight:6}}),p?c?`注入中...`:`Injecting...`:c?`发送转向指令`:`Inject Steering`]})]})]})})}function He(e,t,n=e=>new EventSource(e)){let r=!1,i=n(e),a=()=>!r&&t.alive();return i.onopen=()=>{a()&&(t.connected(!0),t.sync())},i.onerror=()=>{a()&&(t.connected(!1),t.sync())},i.addEventListener(`invalidate`,()=>{a()&&t.sync()}),i.addEventListener(`progress`,e=>{if(a())try{let n=JSON.parse(e.data);if(!n||[n.taskId,n.botId,n.attemptId].some(e=>typeof e!=`string`||!e||e.length>128)||!Number.isSafeInteger(n.sequence)||n.sequence<1||![`model`,`tool`,`waiting`].includes(n.phase)||n.text!==void 0&&(typeof n.text!=`string`||new TextEncoder().encode(n.text).byteLength>2048)||n.toolName!==void 0&&(typeof n.toolName!=`string`||!/^[A-Za-z0-9_.:-]{1,80}$/.test(n.toolName)))return;t.progress({taskId:n.taskId,botId:n.botId,attemptId:n.attemptId,sequence:n.sequence,phase:n.phase,...n.text===void 0?{}:{text:n.text},...n.toolName===void 0?{}:{toolName:n.toolName}})}catch{}}),()=>{r=!0,i.close()}}function Ue(e,t){return!!t&&e.status===`running`&&e.id===t.taskId&&e.botId===t.botId&&e.attemptId===t.attemptId}function We(e,t){return!e||e.attemptId!==t.attemptId||e.sequence<t.sequence}var $=null,Ge=new Set;function Ke(){for(let e of Ge)e()}function qe(e){if(!e){$!==null&&($=null,Ke());return}let t=!!($&&$.roomId===e.roomId),n=t&&$?$.activeRightTab:e.attentionCount>0?`deliveries`:`files`;$&&t&&$.detail===e.detail&&$.devices===e.devices&&$.members===e.members&&$.conversations===e.conversations&&$.attentionCount===e.attentionCount&&$.disabled===e.disabled&&$.conversationError===e.conversationError&&$.activeRightTab===n||($={...$,...e,activeRightTab:n},Ke())}var Je=class extends Error{status;code;constructor(e,t,n=``){super(t),this.status=e,this.code=n}};async function Ye(e,t,n){let i=await fetch(r(o(`/api/device-center/${e}`)),{method:n?`POST`:`GET`,credentials:`same-origin`,signal:AbortSignal.any([t,AbortSignal.timeout(15e3)]),...n?{headers:{"Content-Type":`application/json`},body:JSON.stringify(n)}:{}}),a=await i.json().catch(()=>({}));if(!i.ok)throw new Je(i.status,a.error||String(i.status),a.code??``);return a}var Xe=new Map,Ze=()=>{};function Qe({roomId:e,active:t=!0,onBack:n,uiHeaderSlots:r,uiActionSlots:i}){return(0,X.jsx)($e,{roomId:e,active:t,onBack:n,uiHeaderSlots:r,uiActionSlots:i},e)}function $e({roomId:e,active:t,onBack:n,uiHeaderSlots:i,uiActionSlots:s}){let{locale:c}=a(),l=D(c),[u,d]=(0,J.useState)(null),f=u?.bots??[],[p,m]=(0,J.useState)(``),[h,_]=(0,J.useState)(!1),[v,y]=(0,J.useState)(0),[b,x]=(0,J.useState)(0),[S,C]=(0,J.useState)(!1),[w,T]=(0,J.useState)([]),[E,O]=(0,J.useState)(``),[k,A]=(0,J.useState)(!1),[j,M]=(0,J.useState)(`deliveries`),N=(0,J.useCallback)(e=>{M(e),A(!0)},[]),P=(0,J.useCallback)(()=>{A(!1)},[]),[F,I]=(0,J.useState)(null),[R,B]=(0,J.useState)(null),ee=(0,J.useCallback)(()=>B(null),[]);function te(e){return e instanceof Je&&(e.status===404||e.status===403||e.status===409&&e.code===`REPAIR_REQUIRED`)}function G(e){return e instanceof Je&&e.status===409&&e.code===`REPAIR_REQUIRED`?l?`设备绑定已失效,请返回设备设置重新绑定。`:`Device binding expired. Return to device settings and bind again.`:e instanceof Error?e.message:String(e)}let K=(0,J.useRef)(0),re=(0,J.useRef)(null),q=(0,J.useRef)(null),ie=(0,J.useRef)(!1);(0,J.useEffect)(()=>{let n=++K.current,i=new Map,a=null,s=!1,c=!1,u=null,f=!1;async function p(){if(K.current!==n||!t||document.visibilityState===`hidden`)return;if(f){c=!0;return}c=!1,f=!0,u=new AbortController;let r=u.signal;try{let t=`rooms/${encodeURIComponent(e)}`,[a,o]=await Promise.allSettled([Ye(t,r),Ye(`${t}/conversations`,r)]);if(K.current!==n||r.aborted)return;if(o.status===`fulfilled`&&Array.isArray(o.value.conversations)?(T(o.value.conversations),O(``)):O(l?`无法更新对话列表,请稍后重试。`:`Could not refresh conversations. Try again shortly.`),a.status===`rejected`)throw a.reason;d({...a.value,tasks:a.value.tasks.map(e=>({...e,progress:Ue(e,i.get(e.id))?i.get(e.id):void 0}))});for(let e of i.keys())a.value.tasks.some(t=>Ue(t,i.get(e)))||i.delete(e);_(!1)}catch(e){if(K.current!==n||r.aborted)return;te(e)&&(d(null),_(!0)),m(G(e))}finally{f=!1,c&&K.current===n&&p()}}function h(){K.current===n&&t&&document.visibilityState!==`hidden`&&!a&&typeof EventSource<`u`&&(a=He(r(o(`/api/device-center/rooms/${encodeURIComponent(e)}/events`)),{alive:()=>K.current===n&&document.visibilityState!==`hidden`,sync:()=>{x(e=>e+1),p()},connected:e=>{s=e,C(e)},progress:e=>{let t=i.get(e.taskId);!We(t,e)||i.size>=128&&!t||(i.set(e.taskId,e),d(t=>t&&{...t,tasks:t.tasks.map(t=>Ue(t,e)?{...t,progress:e}:t)}))}}))}p(),h();let g=window.setInterval(()=>{s||p()},2e3),v=()=>{document.visibilityState===`hidden`?(u?.abort(),c=!1,a?.(),a=null,s=!1,C(!1)):(p(),h())};return document.addEventListener(`visibilitychange`,v),()=>{++K.current,C(!1),a?.(),u?.abort(),re.current?.abort(),clearInterval(g),document.removeEventListener(`visibilitychange`,v)}},[e,t,v]);let{state:ae,labels:oe}=(0,J.useMemo)(()=>{let t=u?.room.router?.enabled?{...u,room:{...u.room,primaryBotId:void 0}}:u,n=U(e,t,f,l),r=new Set((u?.messages??[]).filter(e=>String(e.sender.type)===`router`).map(e=>`group-message:${e.id}`)),i=new Map(n.labels);for(let e of r)i.set(e,l?`群组 AI Router`:`Group AI Router`);return{state:{...n.state,messages:n.state.messages.map(e=>r.has(e.id)?{...e,role:`assistant`}:e)},labels:i}},[e,u,f,l]),se=g(),ce=(0,J.useMemo)(()=>V([],{locale:c,t:e=>se(e)}),[c,se]),ue=(0,J.useMemo)(()=>i??(ce[`device.group.header`]??[]).filter(e=>!e.hidden),[i,ce]),de=(0,J.useMemo)(()=>s??(ce[`device.group.actions`]??[]).filter(e=>!e.hidden),[s,ce]),Y=f.filter(e=>e.enabled!==!1&&u?.room.botIds.includes(e.id)),Z=(0,J.useMemo)(()=>w.filter(e=>!!le(e)).length,[w]),Q=(0,J.useMemo)(()=>(u?.tasks??[]).filter(e=>e.status===`running`||e.status===`queued`),[u?.tasks]),fe=(0,J.useCallback)(async t=>{let n=t.conversationId||w.find(e=>e.botId===t.botId&&e.status!==`closed`)?.id;if(n)try{await Ye(`rooms/${encodeURIComponent(e)}/conversations/${encodeURIComponent(n)}/stop`,new AbortController().signal,{}),y(e=>e+1)}catch(e){m(e?.message||(l?`中止任务失败`:`Failed to stop task`))}},[e,w,l]);(0,J.useEffect)(()=>{qe({roomId:e,detail:u,devices:f,members:Y,conversations:w,attentionCount:Z,disabled:!t||h,conversationError:E})},[e,u,f,Y,w,Z,t,h,E]),(0,J.useEffect)(()=>()=>{qe(null)},[]);async function pe(n,r,i,a){if(!t||h||!u||ie.current)return!1;let o=i,s=w.find(e=>e.id===o);if(o&&(!s||s.status===`closed`||E||!Y.some(e=>e.id===s.botId)))return m(l?`所选对话不可用,请重新选择对话或新建任务。`:`Selected conversation is unavailable. Choose a conversation or New task.`),!1;if(s&&r.some(e=>e!==s.botId))return m(l?`继续对话只能发送给原 Bot,请移除其他目标。`:`Continue with the original Bot only. Remove other targets.`),!1;if(r.some(e=>!u.room.botIds.includes(e)))return!1;let c=a?.planOnly===!0,f=s?Y.filter(e=>e.id===s.botId):Y.filter(e=>r.includes(e.id)||!r.length&&!u.room.router?.enabled&&e.id===u.room.primaryBotId);if(c&&f.some(e=>!e.tools?.includes(`plan_update`)))return m(l?`所选 Bot 未授权 plan_update,请先在 Bot 工具白名单中启用。`:`Selected Bot is not authorized to use plan_update. Enable it in the Bot tool allowlist first.`),!1;let p=n.includes(`->`);q.current=z(q.current,JSON.stringify([e,o,c,p]),n,r,L);let g=new AbortController;re.current=g;let v=K.current;ie.current=!0;try{let t=`rooms/${encodeURIComponent(e)}`;return await Ye(o?`${t}/conversations/${encodeURIComponent(o)}/messages`:`${t}/messages`,g.signal,o?{text:n,kind:`message`,idempotencyKey:q.current.key,...c?{planOnly:!0}:{},...p?{pipeline:!0}:{}}:{text:n,targetBotIds:r,idempotencyKey:q.current.key,...c?{planOnly:!0}:{},...p?{pipeline:!0}:{}}),g.signal.aborted||K.current!==v?!1:(q.current=null,m(``),y(e=>e+1),!0)}catch(e){if(!g.signal.aborted&&K.current===v){if(o)return m(l?`继续对话失败,请重试或重新选择目标。`:`Could not continue the conversation. Retry or choose a target.`),!1;te(e)&&(d(null),_(!0)),m(G(e))}return!1}finally{re.current===g&&(ie.current=!1,re.current=null)}}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`dg-head`,children:[(0,X.jsxs)(`div`,{className:`dg-head-info`,children:[(0,X.jsxs)(`div`,{className:`dg-head-brand`,children:[(0,X.jsx)(`span`,{className:`dg-brand-icon`,children:`⚡`}),(0,X.jsx)(`strong`,{className:`dg-head-title`,children:u?.room.name??(l?`联合开发群`:`Group Chat`)})]}),Y.length>0&&(0,X.jsxs)(`button`,{type:`button`,className:`dg-head-pill`,onClick:()=>N(`bots`),title:l?`点击查看协作 Bot 成员详情`:`Click to view collaborating Bots`,children:[(0,X.jsx)(`span`,{className:`dg-head-pill-dot`}),(0,X.jsxs)(`span`,{children:[Y.length,` `,l?`位协作 Bot`:`Bots`]})]})]}),(0,X.jsxs)(`div`,{className:`dg-head-nav`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`router`?`active`:``}`,onClick:()=>N(`router`),title:u?.room.router?.enabled?`${u.room.router.deviceId} · ${u.room.router.model} · ${u.room.router.thinkingLevel}`:l?`未启用 · 沿用原主 Bot 协作`:`Disabled · legacy primary Bot routing`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🧭`}),(0,X.jsxs)(`span`,{className:`dg-nav-text`,children:[`AI Router · `,u?.room.router?.enabled?l?`已启用`:`On`:l?`未启用`:`Off`]})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`work-items`?`active`:``}`,onClick:()=>N(`work-items`),children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🗂`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`工单与运行`:`Work items & runs`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`blackboard`?`active`:``}`,onClick:()=>N(`blackboard`),title:l?`打开群组共享共识黑板`:`Open Group Blackboard`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📋`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`群黑板`:`Blackboard`}),u?.room.blackboard?.version?(0,X.jsxs)(`span`,{className:`dg-nav-badge`,children:[`v`,u.room.blackboard.version]}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`deliveries`?`active`:``} ${Z>0?`has-attention`:``}`,onClick:()=>N(`deliveries`),title:l?`打开交付与待办审查抽屉`:`Open Deliveries & Reviews`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📦`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`交付与待办`:`Deliveries`}),Z>0?(0,X.jsx)(`span`,{className:`dg-nav-badge attention`,children:Z}):w.length>0?(0,X.jsx)(`span`,{className:`dg-nav-badge`,children:w.length}):null]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`transfers`?`active`:``}`,onClick:()=>N(`transfers`),title:l?`打开跨机大文件传输抽屉`:`Open Cross-Device File Transfers`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`📁`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`文件传输`:`Transfers`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`canvas`?`active`:``}`,onClick:()=>N(`canvas`),title:l?`打开群画布工作流抽屉`:`Open Group Canvas`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🎨`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`群画布`:`Canvas`}),u?.room.canvasBinding&&(0,X.jsx)(`span`,{className:`dg-nav-dot active`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`presets`?`active`:``}`,onClick:()=>N(`presets`),title:l?`打开 Bot 预设与规则配置抽屉`:`Open Bot Presets`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🤖`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`Bot 预设`:`Presets`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`bots`?`active`:``}`,onClick:()=>N(`bots`),title:l?`查看成员运行状态与授权工具`:`View Bot Status`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`👥`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`成员状态`:`Bots`})]}),(0,X.jsxs)(`button`,{type:`button`,className:`dg-nav-tab ${k&&j===`webhooks`?`active`:``}`,onClick:()=>N(`webhooks`),title:l?`配置入站与出站 Webhook`:`Configure Incoming and Outgoing Webhooks`,children:[(0,X.jsx)(`span`,{className:`dg-nav-icon`,children:`🔗`}),(0,X.jsx)(`span`,{className:`dg-nav-text`,children:l?`Webhook`:`Webhooks`}),u?.room.webhooks&&u.room.webhooks.filter(e=>e.enabled).length>0&&(0,X.jsx)(`span`,{className:`dg-nav-badge`,children:u.room.webhooks.filter(e=>e.enabled).length})]})]}),(0,X.jsxs)(`div`,{className:`dg-head-actions`,children:[ue.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`btn secondary`,title:e.label,children:e.label},e.id)),n&&(0,X.jsxs)(`button`,{type:`button`,className:`btn dg-back-btn`,onClick:n,title:l?`返回普通对话`:`Back to single chat`,children:[`← `,l?`返回对话`:`Back to chat`]})]})]}),p&&(0,X.jsxs)(`div`,{className:`dg-error-banner`,role:`alert`,children:[p,h?l?`此群聊已删除或你已不在群中,请返回。`:`This group is unavailable or you are no longer a member. Return to chat.`:null]}),(0,X.jsx)(`div`,{className:`dg-tools-shelf collapsed`,"aria-hidden":`true`,style:{display:`none`},children:(0,X.jsxs)(`div`,{className:`dg-tools-shelf-content`,children:[(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(me,{roomId:e,conversations:w,bots:f,disabled:!t||h,error:E})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(Se,{roomId:e,bots:f,disabled:!t||h})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(De,{roomId:e,binding:u?.room.canvasBinding,onSaved:()=>y(e=>e+1)})}),(0,X.jsx)(`div`,{className:`dg-tool-pane`,children:(0,X.jsx)(ke,{bots:Y,onSaved:()=>y(e=>e+1)})})]})}),(Z>0||u?.tasks&&u.tasks.length>0)&&(0,X.jsxs)(`div`,{className:`dg-tasks-strip`,children:[Z>0&&(0,X.jsxs)(`button`,{type:`button`,className:`dg-task-chip dg-attention-chip ${k&&j===`deliveries`?`active`:``}`,onClick:()=>N(`deliveries`),title:l?`点击在协同抽屉中查看需要处理的交付与事项`:`View items needing attention in drawer`,children:[(0,X.jsx)(`span`,{className:`dg-attention-dot`}),(0,X.jsx)(`span`,{className:`dg-attention-text`,children:l?`${Z} 项待处理`:`${Z} need attention`})]}),(()=>{let e=u?.tasks??[],t=e.filter(e=>e.status===`running`||e.status===`waiting`||e.status===`queued`),n=e.slice(-4);if(t.length>0){let r=new Set(t.map(e=>e.id));for(let e of t)e.dependsOnTaskId&&r.add(e.dependsOnTaskId);let i=e.filter(e=>e.status===`completed`).slice(-2);for(let e of i)r.add(e.id);let a=e.filter(e=>r.has(e.id));n=a.length>0?a.slice(-6):e.slice(-6)}return n.map((e,t)=>{let{botPrefix:r,summary:i}=ne(e.text),a=t>0?n[t-1]:void 0,o=t>0&&(e.dependsOnTaskId===a?.id||a?.status===`completed`&&(e.status===`running`||e.status===`waiting`)||e.dependsOnTaskId!==void 0);return(0,X.jsxs)(`div`,{className:`dg-pipeline-step-wrapper`,children:[o&&(0,X.jsx)(`span`,{className:`dg-pipeline-arrow`,title:l?`流水线流转依赖`:`Pipeline flow dependency`,"aria-hidden":`true`,children:`→`}),(0,X.jsxs)(`div`,{className:`dg-task-chip ${e.status===`running`?`is-running`:``} ${e.status===`waiting`?`is-waiting`:``}`,children:[(0,X.jsx)(`span`,{className:`dg-task-status-dot status-${e.status}`,title:e.status===`waiting`?l?`等待前序任务`:`Waiting for upstream`:e.status}),e.status===`waiting`&&(0,X.jsx)(`span`,{className:`dg-task-waiting-badge`,children:l?`⏳ 等待中`:`⏳ Waiting`}),r&&(0,X.jsx)(`strong`,{className:`dg-task-bot-prefix`,children:r}),(0,X.jsx)(`span`,{className:`dg-task-title`,title:e.text,children:i.length>24?i.slice(0,24)+`...`:i}),(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn`,onClick:()=>B(e.id),children:l?`详情`:`Details`}),e.status===`running`&&(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn`,title:l?`飞行中实时注入转向纠偏`:`Inject in-flight steering`,onClick:()=>I(e),children:l?`转向`:`Steer`}),(e.status===`running`||e.status===`queued`||e.status===`waiting`)&&(0,X.jsx)(`button`,{type:`button`,className:`btn dg-task-detail-btn dg-task-stop-action`,title:l?`中止此任务`:`Stop task`,onClick:()=>fe(e),children:l?`中止`:`Stop`})]})]},e.id)})})()]}),(0,X.jsx)(ve,{roomId:e,disabled:!t||h,refreshKey:b,connected:S}),(()=>{let t=u?.tasks.find(e=>e.id===R)??u?.tasks.find(e=>e.status===`running`)??u?.tasks.at(-1);return(0,X.jsx)(Ee,{roomId:e,activeTaskId:t?.id,taskSnapshotRevision:t?.botRevision,planState:t?.plan,uiSlotEntries:de,onStartPlanExecution:t?.status===`completed`?async t=>{await Ye(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}/approve-plan`,new AbortController().signal,{}),y(e=>e+1)}:void 0})})(),(0,X.jsx)(H,{state:ae,liveOutputs:Xe,toolStatuses:Xe,messageLabels:oe,readOnly:!0}),R&&(0,X.jsx)(we,{roomId:e,taskId:R,onClose:ee}),F&&(0,X.jsx)(Ve,{task:F,botName:Y.find(e=>e.id===F.botId)?.name,deviceName:f.find(e=>e.id===F.botId)?.deviceName||F.deviceId,onClose:()=>I(null),onSubmit:async t=>{await Ye(`rooms/${encodeURIComponent(e)}/tasks/${encodeURIComponent(F.id)}/steer`,new AbortController().signal,{text:t.trim()}),y(e=>e+1)}}),(0,X.jsx)(ze,{isOpen:k,activeTab:j,onClose:P,onSelectTab:M,roomId:e,detail:u,devices:f,members:Y,conversations:w,attentionCount:Z,disabled:!t||h,conversationError:E,onRefreshGroup:()=>y(e=>e+1),onRefreshConversations:()=>y(e=>e+1)}),(0,X.jsx)(W,{groupDevices:Y,groupPrimaryBotName:u?.room.router?.enabled?l?`群组 AI Router`:`Group AI Router`:Y.find(e=>e.id===u?.room.primaryBotId)?.name,groupConversations:w,groupConversationError:E,onGroupSend:pe,streaming:Q.length>0,onAbort:Q.length>0?()=>fe(Q[0]):void 0,messages:ae.messages,slashCommands:[],modelState:null,models:[],modelsLoading:!1,attachments:[],onRemoveAttachment:Ze,onAddImageFiles:Ze,onAddLocalFiles:Ze,onNotice:(e,t)=>m(t),onSent:Ze,onManageModels:Ze,providerKeys:{},quickPhrases:[],quickPhrasesEnabled:!1,groupReady:t&&!!u&&!h,sessionId:`device-group:${e}`,conversationId:`device-group:${e}`})]})}export{Qe as GroupConversation};
|